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 is similar to the Feature widget in a side panel sample with the exception that this sample demonstrates working with multiple layers of different types. This sample uses three separate layers: two imagery layers and one feature layer. This sample works with the Popup's fetchFeatures method. This takes a given screen location and returns features from multiple LayerViews. It displays information based on the layer's associated PopupTemplate.

First, listen for the view's click event and pass this into the fetchFeatures method.

view.on("click", function(event) {
  ...
  // Call fetchFeatures and pass in the click event location
  view.popup.fetchFeatures(event).then(function(response) {
   // Do something
  });
});

Next, iterate through all of the returned features to access their associated LayerView and graphics.

 view.popup.fetchFeatures(event).then(function(response) {
   response.promisesPerLayerView.forEach(function(fetchResult) {
     // Do something
   });
  });

Then, loop through the returned graphics from the resulting LayerViews and pass this graphic into the Feature widget's graphic property.

 graphics.forEach(function(graphic) {

   const featureChild = new Feature ({
     container: document.createElement("div"),
     graphic: graphic,
     map: view.map,
     spatialReference: view.spatialReference
   });
 });

Sample search results

TitleSample
Loading...