Perspective Map hover over custom polygon

I am working with the map display and I have outlined a layer to the map using the vector/polygon function. I am trying to find a way to darken the polygon color and display the area of the facility when the mouse hovers over that listed area.

There will be multiple polygon sets as there is multiple areas that are identified and will have different colors/schemes within the layer.

I have tried with using a style, but I have not had luck with that as a function. I have also attempted to use the ‘onMouseOver’ ‘onMouseLeave’ but this seems that it would incorporate all polygons and not allow for different variations for locations on the map.

Any help would be appreciated!

1 Like

onMapMouseMove returns the lat/lng… i suppose you could use that with some maths to deterimne if its inside a polygon…

onVectorClick returns the name of the polygon (much easier) but doesnt trigger on hovers

You could also use theme.css to put some hover events on
.leaflet-interactive

this worked for me for the ‘darken’ part:

.leaflet-interactive {opacity: 0.5;} .leaflet-interactive:hover {opacity: 1;}