A collection of SceneModification with polygons and types to apply client-side modifications. The SceneModifications could be applied to the IntegratedMeshLayer.modifications property.
The modifications for IntegratedMeshLayer need to be in the same spatial reference as the IntegratedMeshLayer. Reprojection between WGS84 and WebMercator will be done automatically. Reprojection of the geometry to other spatial references can be done with the client-side projection engine.
Constructors
-
new SceneModifications(properties)
-
Parameterproperties Objectoptional
See the properties for a list of all the properties that may be passed into the constructor.
Property Overview
Name | Type | Summary | Class |
---|---|---|---|
String | The name of the class. more details | Accessor | |
Number | The number of items in the Collection. more details | Collection |
Property Details
-
The name of the class. The declared class name is formatted as
esri.folder.className
.
-
The number of items in the Collection.
Method Overview
Name | Return Type | Summary | Class |
---|---|---|---|
Adds a single item to the collection. more details | Collection | ||
Adds one or more handles which are to be tied to the lifecycle of the object. more details | Accessor | ||
Adds multiple items to the collection. more details | Collection | ||
* | Returns the item at the specified index, allowing for positive and negative integers. more details | Collection | |
SceneModifications | Creates a clone of this object. more details | SceneModifications | |
Collection | Creates a new Collection containing the items in the original Collection joined with the items in the input array or Collection. more details | Collection | |
Boolean | Emits an event on the instance. more details | Collection | |
Boolean | Determines whether all items in the Collection pass a test defined by | Collection | |
Collection | Filters the Collection's items based on a test defined by the | Collection | |
* | Returns an item in the Collection if that item passes a test as defined in the | Collection | |
Number | Returns the index of an item in the Collection if that item passes a test as defined in the | Collection | |
Collection | Flattens a hierarchical Collection containing at least one child collection. more details | Collection | |
Executes the input function for each item in the Collection. more details | Collection | ||
* | Creates a new instance of this class and initializes it with values from a JSON object generated from an ArcGIS product. more details | SceneModifications | |
* | Returns the item at the specified index. more details | Collection | |
Boolean | Indicates whether there is an event listener on the instance that matches the provided event name. more details | Collection | |
Boolean | Returns true if a named group of handles exist. more details | Accessor | |
Boolean | Tests if an item is present in the new Collection. more details | Collection | |
Number | Returns the index of an element in the collection. more details | Collection | |
String | Creates a string representation of the items in the Collection. more details | Collection | |
Number | Returns the last index of an element in the collection. more details | Collection | |
Collection | Passes each Collection item into the | Collection | |
Object | Registers an event handler on the instance. more details | Collection | |
* | Removes the last item from the collection and returns it. more details | Collection | |
Number | Adds an item(s) to the end of the collection. more details | Collection | |
* | Reduces all items in the collection (from left to right) into a single variable using | Collection | |
* | Reduces all items in the collection (from right to left) into a single variable using | Collection | |
Removes an item from the collection. more details | Collection | ||
Removes all items from the collection. more details | Collection | ||
* | Removes an item from the collection at a specified index. more details | Collection | |
Removes a group of handles owned by the object. more details | Accessor | ||
* | Removes each item in the input array. more details | Collection | |
* | Moves an item in the Collection to a specified index. more details | Collection | |
Collection | Reverses the collection in place. more details | Collection | |
* | Removes the first item from the collection (at index 0), and returns it. more details | Collection | |
Collection | Creates a new Collection comprised of a portion of the original Collection. more details | Collection | |
Boolean | Determines whether an item in the Collection passes a test defined by | Collection | |
Sorts the Collection in place. more details | Collection | ||
Array | Removes existing items and/or adds new items to the collection. more details | Collection | |
Array | Returns a new array object containing the Collection's items. more details | Collection | |
Object | Converts an instance of this class to its ArcGIS portal JSON representation. more details | SceneModifications | |
Number | Adds one or more items to the beginning of the collection. more details | Collection |
Method Details
-
add(item, index)inherited
-
Adds a single item to the collection. The change event is fired after an item is added to the Collection.
Parametersitem *The item to add.
index NumberoptionalZero-based index of where in the collection to add the item. If not specified, the items will be added at the end.
Examplelet gpc = new Graphic(); // Creates a new graphic let layer = new GraphicsLayer(); // Creates a new graphics layer layer.graphics.add(gpc); // Adds graphic to layer's graphics collection
-
addHandles(handleOrHandles, groupKey)inheritedSince: ArcGIS Maps SDK for JavaScript 4.25
-
Adds one or more handles which are to be tied to the lifecycle of the object. The handles will be removed when the object is destroyed.
// Manually manage handles const handle = reactiveUtils.when( () => !view.updating, () => { wkidSelect.disabled = false; }, { once: true } ); this.addHandles(handle); // Destroy the object this.destroy();
ParametershandleOrHandles WatchHandle|WatchHandle[]Handles marked for removal once the object is destroyed.
groupKey *optionalKey identifying the group to which the handles should be added. All the handles in the group can later be removed with Accessor.removeHandles(). If no key is provided the handles are added to a default group.
-
addMany(items, index)inherited
-
Adds multiple items to the collection. The change event is fired after items are added to the Collection.
Parametersitems Array|CollectionAn array or collection of items to add.
index NumberoptionalZero-based index of where in the collection to add the items. If not specified, the items will be added at the end.
Example// Creates two new graphics let gpc1 = new Graphic(); let gpc2 = new Graphic(); let layer = new GraphicsLayer(); // Creates a new graphics layer // Adds both graphics to layer's graphics collection layer.graphics.addMany([gpc1, gpc2]);
-
Since: ArcGIS Maps SDK for JavaScript 4.23
-
Returns the item at the specified index, allowing for positive and negative integers. Negative integers count back from the last item in the array.
Parameterindex NumberIndex of the item in the Collection to retrieve. It can be a relative index from the end of the Collection.
ReturnsType Description * The item in the Collection stored at the specified index. - See also
Example// get the layer at the first position let firstLayer = map.layers.at(0); // get the layer at the last position let lastLayer = map.layers.at(-1);
-
clone(){SceneModifications}
-
Creates a clone of this object.
ReturnsType Description SceneModifications A clone of the SceneModifications instance that invoked this method.
-
-
Creates a new Collection containing the items in the original Collection joined with the items in the input array or Collection.
Parametervalue Array|CollectionThe array or Collection to append to the existing Collection.
ReturnsType Description Collection A new Collection comprised of the items in the Collection that invoked this method combined with the input items. - See also
Example// creating a collection of all the basemap's layers. let basemap = map.basemap; let basemapLayers = basemap.baseLayers.concat(basemap.referenceLayers);
-
Emits an event on the instance. This method should only be used when creating subclasses of this class.
Parameterstype StringThe name of the event.
event ObjectoptionalThe event payload.
ReturnsType Description Boolean true
if a listener was notified
-
Determines whether all items in the Collection pass a test defined by
callback
. Each item in the Collection is passed into the callback until one returns a value offalse
.Parametercallback ItemTestCallbackThe function to call for each item in the Collection.
ReturnsType Description Boolean Returns true
if every call to thecallback
function returnedtrue
. Returnsfalse
if at least one call to thecallback
returnedfalse
.- See also
Examplelet meetsStandardSize = graphicsLayer.graphics.every(function(item, i){ // Tests each geometry's area to see if it is greater than 1,000 acres return calculateArea(item.geometry) > 1000; });
-
-
Filters the Collection's items based on a test defined by the
callback
function. Each item is passed into thecallback
function, which returnstrue
if the item passes the test andfalse
if it does not.Parametercallback ItemTestCallbackThe function that defines a test for determining whether to return the item in a new Collection.
ReturnsType Description Collection Returns a new Collection containing the items that passed the filter test. - See also
Example// filteredLayers is a Collection of all the non-visible layers in the map let filteredLayers = map.layers.filter(function(layer){ return !layer.visible; });
-
-
Returns an item in the Collection if that item passes a test as defined in the
callback
function. Each item is passed into thecallback
function, which returnstrue
if the item passes the test andfalse
if it does not.Parametercallback ItemTestCallbackThe testing function that will assess each item in the Collection. Returns
true
if an item passes the test andfalse
if it fails.ReturnsType Description * The first item in the Collection that satisfies the test function. - See also
Example// If the id of a map layer is already known, get the layer that matches the id let myLayer = map.layers.find(function(layer){ return layer.id === "speciesLyr01"; }); // myLayer references the layer in map with ID "speciesLyr01"
-
Returns the index of an item in the Collection if that item passes a test as defined in the
callback
function. Each item is passed into thecallback
function, which returnstrue
if the item passes the test andfalse
if it does not.Parametercallback ItemTestCallbackThe testing function that will assess each item in the Collection. Returns
true
if an item passes the test andfalse
if it fails.ReturnsType Description Number Returns the index of the Collection item that satsifies the test function. If an item fails the test, -1
is returned.- See also
Example// gpcIndex is assigned the index of the first graphic whose name // property is 'Redlands'. This result can be used in getItemAt() let gpcIndex = graphicsLyr.graphics.findIndex(function(item){ return item.attributes.name === "Redlands"; });
-
-
Flattens a hierarchical Collection containing at least one child collection. Each item in the collection is passed into the
callback
function, which should check for child collections specified by the developer. A flat collection of all items (parent and children) is returned.This is useful for scenarios where the user would like to search all the layers in a map, including a GroupLayer's layers and a MapImageLayer's sublayers. The callback should return the sub-collection of the item. If multiple levels of collections exist in the hierarchy, then this method recursively executes for all sub-collections.
Parametercallback ItemCallbackA function that will assess each item in the Collection.
ReturnsType Description Collection Returns a flat collection of all items in the original collection and their children. Example// create a MapImageLayer with several sublayers and add to a map // containing another GraphicsLayer let layer = new MapImageLayer({ sublayers: [ ... ] }); let map = new Map({ layers: [ layer, new GraphicsLayer() ] }); // A flat collection of all layers and sublayers // (if layer is a MapImageLayer) in the map. // This collection may be searched or used for other purposes let allLayersAndSublayers = map.layers.flatten(function(item){ return item.layers || item.sublayers; });
-
forEach(callback)inherited
-
Executes the input function for each item in the Collection.
Parametercallback ItemCallbackThe function to call for each item in the Collection.
- See also
ExamplegraphicsLayer.graphics.forEach(function(item, i){ // Do something here to each graphic like calculate area of its geometry calculateArea(item.geometry); });
-
fromJSON(json){*}static
-
Creates a new instance of this class and initializes it with values from a JSON object generated from an ArcGIS product. The object passed into the input
json
parameter often comes from a response to a query operation in the REST API or a toJSON() method from another ArcGIS product. See the Using fromJSON() topic in the Guide for details and examples of when and how to use this function.Parameterjson ObjectA JSON representation of the instance in the ArcGIS format. See the ArcGIS REST API documentation for examples of the structure of various input JSON objects.
ReturnsType Description * Returns a new instance of this class.
-
-
Returns the item at the specified index.
Parameterindex NumberZero-based index of the item in the Collection to retrieve.
ReturnsType Description * The item in the Collection stored at the specified index. Example// Assigns the base layer at index 0 to baseLayer let baseLayer = map.basemap.baseLayers.getItemAt(0);
-
Indicates whether there is an event listener on the instance that matches the provided event name.
Parametertype StringThe name of the event.
ReturnsType Description Boolean Returns true if the class supports the input event.
-
Since: ArcGIS Maps SDK for JavaScript 4.25
-
Returns true if a named group of handles exist.
ParametergroupKey *optionalA group key.
ReturnsType Description Boolean Returns true
if a named group of handles exist.Example// Remove a named group of handles if they exist. if (obj.hasHandles("watch-view-updates")) { obj.removeHandles("watch-view-updates"); }
-
Tests if an item is present in the new Collection.
ParametersearchElement *The item to search for in the collection.
ReturnsType Description Boolean true
if the item is in the collection.- See also
Example// check if a layer is in the map's operational layers. if (view.map.layers.includes(myLayer)) { // ... }
-
Returns the index of an element in the collection.
ParameterssearchElement *Item to search for in the collection.
fromIndex NumberoptionalUse if you don't want to search the whole collection or you don't want to search from the start.
ReturnsType Description Number The location of the first match found in the collection, or -1 if there is no match. - See also
Example// index is the index of the first graphic in the // graphics layer that matches the input graphic let index = graphicsLayer.graphics.indexOf(graphic);
-
Creates a string representation of the items in the Collection.
Parameterseparator StringoptionalDefault Value: ,The separator used between each item in the final string.
ReturnsType Description String The string representation of the items. - See also
Examplelet stringCollection = new Collection(["how", "are", "you", "doing?"]); let phrase = stringCollection.join(" "); // Prints "how are you doing?" console.log(phrase);
-
Returns the last index of an element in the collection.
ParameterssearchElement *Item to search for in the collection.
fromIndex NumberoptionalUse if you don't want to search the whole collection, or you don't want to search from the end.
ReturnsType Description Number The location of the last match found in the collection, or -1 if there is no match. - See also
Example// index is the index of the first graphic in the // graphics layer that matches the input graphic let index = graphicsLayer.graphics.lastIndexOf(graphic);
-
-
Passes each Collection item into the
callback
function and returns a new array of the returned values. For example, if you have a Collection of numbers and would like to add each number by 10, you can usemap()
to create a new Collection with the same numbers incremented by 10.Parametercallback ItemMapCallbackThe function that processes each item in the Collection and returns a new value at the same index of the original item.
ReturnsType Description Collection Returns a new collection containing the new items generated from the callback
.- See also
Example// Gets the geometries of the graphics and assigns them to a new Collection let geoms = graphicsLayer.graphics.map(function(item, i){ return item.geometry; });
-
Registers an event handler on the instance. Call this method to hook an event with a listener.
ParametersAn event or an array of events to listen for.
listener FunctionThe function to call when the event fires.
ReturnsType Description Object Returns an event handler with a remove()
method that should be called to stop listening for the event(s).Property Type Description remove Function When called, removes the listener from the event. Exampleview.on("click", function(event){ // event is the event handle returned after the event fires. console.log(event.mapPoint); });
-
-
Removes the last item from the collection and returns it.
ReturnsType Description * The last item in the collection. - See also
Example// Removes the last layer in the map and stores it in lastLayer let lastLayer = map.layers.pop();
-
Adds an item(s) to the end of the collection.
Parameteritem *An item or comma-separated list of items to add to the end of the collection.
ReturnsType Description Number The new length of the collection. - See also
Examples// Adds a new graphic to the end of the graphics collection on a GraphicsLayer graphicsLyr.graphics.push(newGraphic);
// Adds three new graphics to the end of the GraphicsLayer's graphics collection graphicsLyr.graphics.push(g1, g2, g3);
-
-
Reduces all items in the collection (from left to right) into a single variable using
callback
.Parametercallback ItemReduceCallbackThe function that processes each item in the Collection and appends it to the previous item.
ReturnsType Description * Returns the value representing the reduction of the Collection's items. - See also
-
-
Reduces all items in the collection (from right to left) into a single variable using
callback
.Parameterscallback ItemReduceCallbackThe function that processes each item in the Collection and appends it to the previous item.
initialValue *optionalItem to use as the first element to process in
callback
.ReturnsType Description * Returns the value representing the reduction of the Collection's items. - See also
-
remove(item)inherited
-
Removes an item from the collection. The change event is fired after an item is removed from the Collection.
Parameteritem *The item to remove.
Examplelet layer = map.layers.getItemAt(4); // Removes the fifth layer from the map map.layers.remove(layer);
-
removeAll()inherited
-
Removes all items from the collection.
Example// Removes all layers from the map map.layers.removeAll();
-
-
Removes an item from the collection at a specified index. The change event is fired after an item is removed from the Collection.
Parameterindex NumberThe index of the item to remove..
ReturnsType Description * The removed item if present in the collection, undefined
otherwise.Example// Removes the layer at index 4 of the map map.layers.removeAt(4);
-
removeHandles(groupKey)inheritedSince: ArcGIS Maps SDK for JavaScript 4.25
-
Removes a group of handles owned by the object.
ParametergroupKey *optionalA group key or an array or collection of group keys to remove.
Exampleobj.removeHandles(); // removes handles from default group obj.removeHandles("handle-group"); obj.removeHandles("other-handle-group");
-
-
Removes each item in the input array. If an item is present multiple times in the collection, only the first occurrence is removed. The change event is fired after an item is removed from the Collection.
Parameteritems Array|CollectionThe items to remove.
ReturnsType Description * The removed items present in the collection. Examplelet refLayers = [refLyr1, refLyr2, refLyr3]; // Removes three reference layers in the refLayers // collection from the basemap's referenceLayers map.basemap.referenceLayers.removeMany(refLayers);
-
-
Moves an item in the Collection to a specified index. The change event is fired after an item is moved in the Collection.
Parametersitem *The item to move.
index NumberThe index to move the item to.
ReturnsType Description * The item that was moved. undefined
ifitem
is not in the collectionExample// Get the first two layers in a map let layer1 = map.layers.getItemAt(0); let layer2 = map.layers.getItemAt(1); // Moves the second layer to the first position in the map.layers Collection // effectively swapping the positions of layer1 and layer2 map.layers.reorder(layer2, 0);
-
-
Reverses the collection in place.
ReturnsType Description Collection The reversed collection. - See also
Example// Reverse layers from the map map.layers.reverse();
-
-
Removes the first item from the collection (at index 0), and returns it. The remaining items of the collection are then shifted down one index from their previous location.
ReturnsType Description * The first item in the collection. - See also
Example// Removes the first layer in the map and stores it in firstLyr let firstLyr = map.layers.shift();
-
-
Creates a new Collection comprised of a portion of the original Collection.
Parametersbegin NumberoptionalThe index of the first item to extract.
end NumberoptionalThe index of the last item to extract.
ReturnsType Description Collection Returns a new Collection containing the items in the specified range. - See also
Example// get the graphics from index 50 to 100; let selection = graphicsLayer.graphics.slice(50, 100);
-
Determines whether an item in the Collection passes a test defined by
callback
. Each item in the Collection is passed into the callback until one returns a value oftrue
.Parametercallback ItemCallbackThe function that defines the test for each Collection item.
ReturnsType Description Boolean Returns true
if any of the items in the Collection pass the test defined incallback
. Returnsfalse
if all items fail the test.- See also
Example// If at least one of the point graphics has a geometry whose // elevation is above 1000m, then passes will have a value of true. // Otherwise, it will be false. let passes = graphicsLayer.graphics.some(function(item, i){ return item.geometry.z > 1000; });
-
sort(compareFunction)inherited
-
Sorts the Collection in place.
ParametercompareFunction ItemCompareCallbackoptionalThe function that defines a comparison of two items in the collection.
- See also
Example// Sort graphics based on their elevation or z-value let sortedGraphics = graphicsLayer.graphics.sort(function(a, b){ if(a.geometry.z > b.geometry.z){ return 1; } else if (a.geometry.z < b.geometry.z){ return -1; } else { return 0; } });
-
Removes existing items and/or adds new items to the collection.
Parametersstart NumberIndex at which to start changing the collection.
deleteCount NumberIndicates the number of collection items to remove. If
0
is used then no elements are removed and at least one new item should be added in theitems
parameter.items *The item or comma-separated list of items to add to the collection.
ReturnsType Description Array An array of the deleted items formerly part of the collection. - See also
Examples// map.layers is a collection of 6 layers // Adds a seventh layer to the map at index 3 map.layers.splice(3, 0, layer7);
// Removes two layers starting from index 2 and adds the // specified layers in the positions of the former layers let oldLayers = map.layers.splice(2, 2, layer8, layer9, layer10); // oldLayers = [layer2, layer3]
-
Returns a new array object containing the Collection's items.
ReturnsType Description Array An array containing the Collection's items. Example// Creates an array populated with the map's layers let mapLayersArray = map.layers.toArray();
-
toJSON(){Object}
-
Converts an instance of this class to its ArcGIS portal JSON representation. See the Using fromJSON() guide topic for more information.
ReturnsType Description Object The ArcGIS portal JSON representation of an instance of this class.
-
Adds one or more items to the beginning of the collection.
Parameteritems *The item(s) to add to the beginning of the collection.
ReturnsType Description Number The new length of the collection. - See also
Example// If a map's basemap has 3 baseLayers: baseLyr0, baseLyr1, baseLyr2 map.basemap.baseLayers.unshift(baseLyr3); // Now the baseLayers collection is: baseLyr3, baseLyr0, baseLyr1, baseLyr2
Event Overview
Name | Type | Summary | Class |
---|---|---|---|
{item: *} |
Fires after an item has been added to the collection. more details |
Collection | |
Fires after an item has been added, reordered or removed from the collection. more details |
Collection | ||
{item: *} |
Fires after an item has been removed from the collection. more details |
Collection | |
{cancellable: Boolean,defaultPrevented: Boolean,item: *,preventDefault: Function} |
Fires before an item is added to the collection. more details |
Collection | |
{cancellable: Boolean,defaultPrevented: Boolean,item: *,preventDefault: Function} |
Fires before any modifications are performed on the collection. more details |
Collection | |
{cancellable: Boolean,defaultPrevented: Boolean,item: *,preventDefault: Function} |
Fires before an item has been removed from the collection. more details |
Collection | |
{added: Array,moved: Array,removed: Array} |
Fires after an item has been added, reordered, or removed from the Collection. more details |
Collection |
Event Details
-
after-addinherited
-
Fires after an item has been added to the collection.
- Property
-
item *
The item added to the collection.
Example// indicates a layer has been added to the map map.layers.on("after-add", function(event){ console.log(event.item, " has been added to the map."); });
-
after-changesinherited
-
Fires after an item has been added, reordered or removed from the collection.
Examplemap.layers.on("after-changes", function(event){ console.log(event, " layer was added/removed from the map."); });
-
after-removeinherited
-
Fires after an item has been removed from the collection.
- Property
-
item *
The item to remove from the collection.
Example// indicates a layer has been removed from the map map.layers.on("after-remove", function(event){ console.log(event.item, " has been removed from the map."); });
-
before-addinherited
-
Fires before an item is added to the collection. This event can be used to prevent an item from being added to the collection by cancelling it with the
event.preventDefault()
method.- Properties
-
cancellable Boolean
Indicates if the change event can be cancelled.
defaultPrevented BooleanIndicates if this event has previously been cancelled by another event handler.
item *The item to add to the collection.
preventDefault FunctionA method that prevents the item from being added to the collection.
Example// prevents a layer from being added to the map more than once. map.layers.on("before-add", function(event){ if(map.layers.includes(event.item)){ event.preventDefault(); console.log("layer already exists in map."); } });
-
before-changesinherited
-
Fires before any modifications are performed on the collection. This event can be used to prevent an item from being added or removed from the collection by cancelling it with the
event.preventDefault()
method.- Properties
-
cancellable Boolean
Indicates if the change event can be cancelled.
defaultPrevented BooleanIndicates if this event has previously been cancelled by another event handler.
item *The item to add or remove from the collection.
preventDefault FunctionA method that prevents the item from being added or removed from the collection.
Examplemap.layers.on("before-changes", function(event){ // prevents layers from being added/removed from the map event.preventDefault(); });
-
before-removeinherited
-
Fires before an item has been removed from the collection. This event can be used to prevent an item from being removed from the collection by cancelling it with the
event.preventDefault()
method.- Properties
-
cancellable Boolean
Indicates if the change event can be cancelled.
defaultPrevented BooleanIndicates if this event has previously been cancelled by another event handler.
item *The item to remove from the collection.
preventDefault FunctionA method that prevents the item from being removed from the collection.
Example// prevents a layer from being removed from the basemap map.basemap.baseLayers.on("before-remove", function(event){ if(map.basemap.baseLayers.includes(event.item)){ event.preventDefault(); console.log("layer cannot be removed from basemap."); } });
-
changeinherited
-
Fires after an item has been added, reordered, or removed from the Collection. Using methods of other classes that affect properties of type Collection will also cause this event to fire, such as Map.add(), Map.remove(), Map.reorder().
For example,
map.layers.add(newLyr)
andmap.add(newLyr)
which uses Map.add() to add a new layer to themap.layers
collection will cause this event to fire.The change event can be used to notify the developer/user of changes to the collection.
- Properties
-
added Array
An array of items added to the collection using either add() or addMany().
moved ArrayAn array of items that moved in the collection using reorder().
removed ArrayAn array of items removed from the collection using either remove(), removeMany(), removeAt(), or removeAll().
Example// This function will fire each time a layer is either added, // moved, or removed from the map.layers Collection map.layers.on("change", function(event){ let newLayers = event.added; // An array of layers added to the map.layers Collection let reorderedLayers = event.moved; // An array of layers moved in the Collection let removedLayers = event.removed; // An array of layers removed from map });