[GIS] resetStyle in geoJSON pointToLayer circleMarkers

leaflet

I am creating a geoJSON layer, with pointToLayer returning circleMarkers. In that layer's oneachfeature, I am triggering a style change on hover, and this works fine. However, I cannot reset the style on mouseout. It all works with lines and polygons, but not with points created as circleMarkers via pointToLayers.

How can I reset the style of such circleMarkers on mouseout?

Best Answer

One method is to create your own reset function using setStyle to be run on mouseout. For example:

function resetHighlight(e) {
    var layer = e.target;
    layer.setStyle(StyleDefault);
}

(where StyleDefault is your default circleMarker style, defined elsewhere)

Here is an example fiddle using some synthetic data.

Related Question