Closed garretto closed 4 years ago
+1
Although for now, you could just add pmIgnore to the CircleMarker() and marker(). That is, if you use pointToLayer.. Which isn't always applicable..
Decent workaround for now, thanks!
Good find, thanks you π Will fix it
This is so weird. The options are properly passed from L.geoJson to path layers but for markers no options show up π€. Still looking
Alright, I think this could be a leaflet issue. I've reported it in here π
@codeofsumit This was merged into Leaflet master the other day π @garretto
same for other geoJSON layers - e.g. when initPolygon() from L.PM is run for L.geoJSON, options are not YET set - this is timing issue (as they are set just after). I'm not sure yet how & where this should be handled - but for a work-around initPolygon() might check: this.options.style.pmIgnore instead - that is there.
The Leaflet Issue is closed and PR is merged https://github.com/Leaflet/Leaflet/issues/6858 Solution: markersInheritOptions
If you set markersInheritOptions
to true and you have NO pointToLayer
function, the global options from the geoJson layer are passed to the markers.
L.geoJSON(geojson, {
pmIgnore: true,
markersInheritOptions: true
}).addTo(map);
If you want to use pointToLayer
you have to add pmIgnore
to the marker creation.
L.geoJSON(geojson, {
pmIgnore: true,
pointToLayer: function (feature, latlng) {
return L.circleMarker(latlng, {
pmIgnore: true
});
},
}).addTo(map)
The pmIgnore flag is not respected with GeoJSON markers and points. In the following example, pmIgnore flag is set and respected by other GeoJSON features, but not markers and points:
https://jsfiddle.net/yousnk53/