MapImageLayer - create dynamic map layers

Note: Support for 3D on mobile devices may vary, view the system requirements for more information.

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: {
      type: "class-breaks",
      // set other renderer properties in this object
    },
    source: {
      mapLayerId: 1
    }
  }, {
    id: 11,
    renderer: {
      type: "unique-value",
      // set other renderer properties in this object
    },
    definitionExpression: "POP07_SQMI >= 5100",
    source: {
      mapLayerId: 1
    }
  }, {
    id: 12,
    renderer: {
      type: "simple",
      // set other renderer properties in this object
    },
    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

TitleSample

There were no match results from your search criteria.