MapImageLayer - create dynamic map layers
This sample demonstrates how to create dynamic map layers in a MapImageLayer. A dynamic map layer allows you to alter properties of a map service layer on the fly including labels, renderers, visibility, and definition expressions. A dynamic layer is created as a sublayer to a MapImageLayer. This means that multiple dynamic layers can point to the same map service layer so you can essentially copy layers from the same data source to the MapImageLayer.
In the snippet below, three sublayers are added to a MapImageLayer. The id property of the sublayer does not refer to the layer ID of the service layer in this case. Rather it is determined by the user to uniquely identify the layer. The service layer's layer ID is referenced in the mapLayerId
property of the source. The source type in this case is map-layer
, which is inferred by the user or developer when they set the mapLayerId
property. Notice how all three layers point to the same source layer ID, but alter the properties of that layer dynamically in different ways.
var layer = new MapImageLayer({
url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer",
sublayers: [{
id: 10,
renderer: new ClassBreaksRenderer( ... ),
source: {
mapLayerId: 1
}
}, {
id: 11,
renderer: new UniqueValueRenderer( ... ),
definitionExpression: "POP07_SQMI >= 5100",
source: {
mapLayerId: 1
}
}, {
id: 12,
renderer: new SimpleRenderer( ... ),
definitionExpression: "POP07_SQMI >= 5100",
source: {
mapLayerId: 1
}
}]
});
To see the default renderers for layers in the map service, either remove the renferences to the renderers defined in this sample or view the MapImageLayer - Toggle sublayer visibility sample.
Sample search results
Title | Sample |
---|
There were no match results from your search criteria.