MapImageLayer - Set definition expressions on sublayers

This device does not support 3D.

View the system requirements for more information.

This sample shows how add an instance of MapImageLayer to a Map in a MapView and update the definitionExpression of a sublayer.

// This layer has four sublayers. You can define the definitionExpression in each sublayer.
var layer = new MapImageLayer({
  url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer",
  sublayers: [
    {
      id: 3,
      visible: false
    },
    {
      id: 2,
      visible: true
    },
    {
      id: 1,
      visible: true
    },
    {
      id: 0,
      visible: true,
      definitionExpression: "pop2000 > 100000"
    }
  ]
});

...

/*****************************************************************
* Listen for events on when the slider values have changed.
* When the slider value changes, apply the new value to the
* MapImageLayer definitionExpression.
*****************************************************************/
layer.then(function() {
  var cities = layer.findSublayerById(0);
  var slider = document.querySelector(".population-slider");
  var total = document.querySelector(".total");
  on(slider, "change", function() {
    cities.definitionExpression = "pop2000 > " + slider.value;
  });
  on(slider, "input", function() {
    total.innerText = number.format(parseInt(slider.value));
  });
});

Sample search results

TitleSample

There were no match results from your search criteria.