You are using a browser that is no longer supported. Please use the latest version of Google Chrome, Mozilla Firefox, Apple Safari, or Microsoft Edge. For more information please see the System Requirements.

Unsupported browser

You are using a browser that is not supported. JavaScript API works on the latest versions of Google Chrome, Mozilla Firefox, Apple Safari, or Microsoft Edge. Use one of these browsers and provide your feedback through GeoNet, the Esri Community.

  • {i18n.unsupportedBrowser.chrome}
  • Firefox
  • Safari
  • undefined
Loading...

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

This sample shows how to 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.when(function() {
  var cities = layer.findSublayerById(0);
  populationSlider.on("thumb-drag", populationValueChanged);
  function populationValueChanged(event) {
    selectedPopulation = event.value;
    document.getElementById("population-display").innerHTML = parseInt(selectedPopulation).toLocaleString()
    // update the layers after the user stops the slider to avoid continues requests
    if (event.state === 'stop')
    {
      cities.definitionExpression = "pop2000 > " + selectedPopulation;
    }
  }
});

Sample search results

TitleSample
Loading...