Javascript API 4.2X Removing highlight from a specific feature (not all features)

2829
10
Jump to solution
11-29-2021 11:27 AM
ShellyM
New Contributor III

Hi everyone,

I am using the highlight method (https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-FeatureLayerView.htm... https://developers.arcgis.com/javascript/latest/sample-code/highlight-point-features/) on the map view to highlight individual points one by one based on user input from another part of my application.

 

highlighted = mapView.highlight(feature);

 

Given that there are multiple features highlighted, is there a way to selectively remove the highlight from a feature (perhaps using the ObjectId or attribute) without removing the highlight from all of the features?

Every example that I've seen so far suggests removing all of the highlights and then creating a new highlight with the new graphic or array of graphics, like so.

 

if (highlighted) {
     highlighted.remove();
}

highlighted = mapView.highlight(feature);  // new graphic or array of graphics

 

This technically works, but it creates an undesirable effect where the highlighted features briefly flash before showing the new highlighted selection. If possible, I do not want the highlighted features to flash when removing/updating a highlight.

I've been looking into this for a while now and haven't found a solution. I'm hoping there is some way to do it. It looks possible because the Feature Table widget has a highlightOnRowSelectEnabled property, and that works smoothly when adding/removing highlights, but I don't know if any part of that is transferable here.

Any help is much appreciated. Thanks in advance!

0 Kudos
10 Replies
BlakeTerhune
MVP Regular Contributor

The API is changing quickly so I appreciate the follow-up reply @shaylavi!

0 Kudos