geoman-io / leaflet-geoman

πŸ‚πŸ—ΊοΈ The most powerful leaflet plugin for drawing and editing geometry layers
https://geoman.io
MIT License
2.21k stars 433 forks source link

pmIgnore not working with GeoJSON markers and points #508

Closed garretto closed 4 years ago

garretto commented 5 years ago

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/

Dan-Wood commented 5 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..

https://jsfiddle.net/0sh457gb/

garretto commented 5 years ago

Decent workaround for now, thanks!

codeofsumit commented 5 years ago

Good find, thanks you πŸ‘ Will fix it

codeofsumit commented 5 years ago

This is so weird. The options are properly passed from L.geoJson to path layers but for markers no options show up πŸ€”. Still looking

codeofsumit commented 5 years ago

Alright, I think this could be a leaflet issue. I've reported it in here πŸ‘†

Dan-Wood commented 4 years ago

@codeofsumit This was merged into Leaflet master the other day πŸ‘ @garretto

Sayene commented 4 years ago

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.

Falke-Design commented 4 years ago

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)