Hi folks,
I am selecting features from all layers on my map and now i want to highlight all selected features. I do it using this code:
let highlight;
map.allLayers.forEach(layer => {
// Query all layers data
if (layer.type === "feature" && layer.visible){
layer.queryFeatures(query)
.then((results) => {
const graphics = results.features;
// console.log(graphics);
// do something with query results
highlight = highlight(graphics);
})
}
});
But i get error: Uncaught (in promise) TypeError: highlight is not a function;
How can i simply achive this?
Thanks
Solved! Go to Solution.
Highlight is a method on the LayerView, so you need a reference to the LayerView that your features come from.
You get a reference to the LayerView for each layer using the view.whenLayerView method.
https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#whenLayerView
Then you can use the layerView to highlight the features you are interested in.
Here is one of a few samples that show how to use highlight
Highlight is a method on the LayerView, so you need a reference to the LayerView that your features come from.
You get a reference to the LayerView for each layer using the view.whenLayerView method.
https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#whenLayerView
Then you can use the layerView to highlight the features you are interested in.
Here is one of a few samples that show how to use highlight
Thank you @ReneRubalcava , you helped me, awesome!