Loading...

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

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.

var 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 renferences to the renderers defined in this sample or view the MapImageLayer - Toggle sublayer visibility sample.

17 results for Sample Code:

Tags
TitleSample
IntegratedMeshLayer Explore in the sandboxSandbox CodePen View live
PopupTemplate - use functions to set content Explore in the sandboxSandbox CodePen View live
Save a web scene Explore in the sandboxSandbox CodePen View live
Query features from a FeatureLayer Explore in the sandboxSandbox CodePen View live
Themes Explore in the sandboxSandbox CodePen View live
Responsive widgets Explore in the sandboxSandbox CodePen View live
Geoprocessing - hotspot analysis Explore in the sandboxSandbox CodePen View live
Intro to CSVLayer Explore in the sandboxSandbox CodePen View live
Custom popup actions per feature attribute Explore in the sandboxSandbox CodePen View live
Using Esri Icon Fonts with map graphics Explore in the sandboxSandbox CodePen View live
Track current location Explore in the sandboxSandbox CodePen View live
MapImageLayer - set renderers on sublayers Explore in the sandboxSandbox CodePen View live
Access features with pointer events Explore in the sandboxSandbox CodePen View live
MapImageLayer - dynamic data layer with query table Explore in the sandboxSandbox CodePen View live
MapImageLayer - label sublayer features Explore in the sandboxSandbox CodePen View live
MapImageLayer - raster data source Explore in the sandboxSandbox CodePen View live
MapImageLayer - dynamic data layer with table join Explore in the sandboxSandbox CodePen View live
Loading...