Skip To ContentArcGIS for DevelopersSign In Dashboard
Loading...

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

This sample shows how to use the hitTest() method on the MapView to access features in a FeatureLayer. This is done by setting up a pointer-move event handler on the view and passing the returned screen x, y coordinates to the hitTest() method of the view. A promise is returned, which resolves to an array of objects containing any features from various layers. Then the sample checks if any feature from a FeatureLayer, in this case hurricanesLayer, is returned, and if there is a hit then the sample displays an information pertaining to this feature.

view.on("pointer-move", function(event) {
  view.hitTest(event).then(function(response) {
    // check if a feature is returned from the hurricanesLayer
    // do something with the result graphic
    const graphic = response.results.filter(function(result) {
      return result.graphic.layer === hurricanesLayer;
    })[0].graphic;
  });
});

The sample displays hurricane paths. Click any line segment to view some of its attributes and assign the same symbol to all line segments with the same storm name.

Sample search results

TitleSample
Loading...