Select to view content in your preferred language

Highlight

1012
2
04-03-2021 03:05 PM
Med-Karim-Rouissi
Emerging Contributor

Hello,

In this example:

https://developers.arcgis.com/javascript/latest/sample-code/sandbox/index.html?sample=featurelayervi...

we can select the entities directly by click, or via the menu on the right, everything works fine, but what I do not understand there is no mention in the code of "highlight", how to explain that !?

Tags (2)
0 Kudos
2 Replies
JeffreyWilkerson
Frequent Contributor

Some of the Esri samples strive to show us one thing, but obfuscate what else is happening.  In this case, I think the highlighting is done through the MapView class.  If you set 'highlightOptions' on load then any click event will use that to highlight the selected graphic.  The 'listNode.addEventListener("click", onListClickHandler)' declaration is handling the click event for the right side click, but I think the MapView is by default handling the map click event, which then triggers the MapView update which then uses the current 'highlightOptions' to draw the selection.  If you look at the bottom of the Mapview class it specifies inherited events.  You can attach to these to get access to the click (and the selected graphics) if needed, but if you just want to modify how the highlight looks then I would look at the 'highlightOptions'.

 

BlakeTerhune
MVP Regular Contributor

I think the feature is highlighted like that by default when the popup is opened. See here for another example. If you wanted to highlight the feature without a popup in the way, you would have to do that manually.