How to highlight a feature in the layer. 1st image shows the layer and 2nd image is the selected feature highlighted on click.How to do this ?
3 Answers
Assuming that the Vector Layer screenshot you've linked to has polygon data and isn't just a Raster Layer, you can use Feature State to accomplish this. Here's an example of using feature state to modify styling at runtime on the client: https://docs.mapbox.com/mapbox-gl-js/example/hover-styles/
For your purposes, rather than using the "mousemove"
& "mouseleave"
events that the above example uses, you can use the "click"
event to trigger your polygon's style change.
⚠️ Disclaimer: I currently work for Mapbox ⚠️
2 Comments
Maybe this issue can help?
https://gis.stackexchange.com/questions/326243/mapbox-gl-feature-manipulation/326394#326394
You have to alter the color properties and reset the source