Hi all,
Can someone point me how to remove highlight from all features on map? I have several layers (5 layers) and i want to remove highlight at once from all them.
Thank you in advance
Solved! Go to Solution.
Hi there,
This test app shows how to remove highlights from several layersviews at a time.
Hope this helps,
-Undral
Which version of the JavaScript API are you using, 3.x or 4.x?
I can provide you with a little example (using 4.13) where a parcel is highlighted when clicked and 'unhighlighted' when the popup is closed: Aan de slag met ArcGIS JavaScript - DKK Geocoder
The relevant piece of code is shown below. But, as you can see from my notes, it was not me who figured this out. No it was Robert Scheitlin, GISP...
Is this example useful to you?
Cheers,
Egge-Jan
// Make sure the clicked parcel is highlighted - code sample provided by Robert Scheitlin, GISP on GeoNet
view.popup.watch('selectedFeature', function(gra){
if(gra){
view.graphics.removeAll();
let h = view.highlightOptions;
gra.symbol = {
type: "simple-fill", // autocasts as new SimpleFillSymbol()
color: [h.color.r,h.color.g, h.color.b, h.fillOpacity],
outline: {
// autocasts as new SimpleLineSymbol()
color: [h.color.r,h.color.g, h.color.b, h.color.a],
width: 1
}
};
view.graphics.add(gra);
}else{
view.graphics.removeAll();
}
});
view.popup.watch('visible', function(vis){
if(!vis){
view.graphics.removeAll();
}
});
Hi Egge-Jan,
I use 4.14 version,
i tried view.graphics.removeAll(),
but it didn't work. It removes for one layer, but when i try to use it for
muktuple it doesn't work.
Hi there,
This test app shows how to remove highlights from several layersviews at a time.
Hope this helps,
-Undral
Thanks for the nudge in the right direction. I didn’t think about the fact that the highlight method is returning a value that I can use. On to the next ArcGIS problem.