MapImageLayer - set renderers on sublayers

The sublayers property of a MapImageLayer allows you to dynamically set renderers on the fly for layers in a map service. To do so, you must reference the layer ID of the service layer and assign a renderer to the renderer property of the sublayer.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
const layer = new MapImageLayer({
  url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer",
  sublayers: [
    {
      id: 2,
      renderer: {
        type: "simple", // autocasts as new SimpleRenderer()
        symbol: {
          type: "simple-marker", // autocasts as new SimpleMarkerSymbol()
          size: 3,
          color: "white"
        }
      }
    }
  ]
});

To see the default renderers for layers in the map service, either remove the references to the renderers defined in this sample or view the MapImageLayer - Toggle sublayer visibility sample.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.

The developer dashboard has moved

You can no longer sign into this site. Go to your ArcGIS portal or the ArcGIS Location Platform dashboard to perform management tasks.

Your ArcGIS portal

Create, manage, and access API keys and OAuth 2.0 developer credentials, hosted layers, and data services.

Your ArcGIS Location Platform dashboard

Manage billing, monitor service usage, and access additional resources.

Learn more about these changes in the What's new in Esri Developers June 2024 blog post.

Close