Access features with click events
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 click 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 a GraphicsLayer or FeatureLayer.
view.on("click", function(event){
view.hitTest(event)
.then(function(response){
var graphic = response.results[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.