Add markercluster Identification Property
See original GitHub issue- I’m reporting a bug, not asking for help
- I’m sure this is a Leaflet.MarkerCluster code issue, not an issue with my own code nor with the framework I’m using (Cordova, Ionic, Angular, React…)
- I’ve searched through the issues to make sure it’s not yet reported
Hi all! I’m the author of leaflet drawing plugin leaflet.pm and I’m currently trying to make our two plugins work together (https://github.com/codeofsumit/leaflet.pm/issues/316).
If developers are using both our plugins, spiderlegs are editable and drag & edit features affect the whole marker group instead of single markers. Also the cluster-marker becomes editable.
As far as I see it, leaflet.pm should basically only consider “core” layers/markers and ignore helper markers of any plugins. I consider the cluster-marker and the spiderlegs to be helpers of the markercluster plugin.
My issue currently is to identify layers from markercluster. I’m checking against the _group
and _markerCluster
property. I could not find any way to identify a Spiderleg layer, so I additionally check markers for _spiderLegs
and remove leaflet.pm classes after their initialization. This is far from ideal and sprinkles markercluster specific if-else statements across the library code.
Suggestion:
In leaflet.PM I’ve added pmTempLayer: true
to any helper-layer that is created by the library for others to identify and ignore, if necessary. Would it make sense to introduce a similar property like markerclusterHelper: true
to the cluster-marker and spiderlegs to easily identify them?
With that, I could check for that property and ignore these layers.
Alternative
If you would like to add leaflet.PM compatibility to markercluster from your side, you could also add the option pmIgnore: true
to all cluster-marker and the spiderlegs and they’re ignored automatically by leaflet.pm. I’d be happy to create a PR for this if this is an option for you.
What do you think?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:6 (3 by maintainers)
Top GitHub Comments
@danzel I was able to make editing of my plugin work together with markercluster:
(spiderlegs are getting ignored and clustermarker updates correctly 👍 )
But I still have some problems with the removal of markers. When I fan out a cluster and delete a marker from the cluster it seems as if markercluster events are getting lost. The icon is not updated, I can’t collapse the cluster again, mouse events do not work anymore. No error is thrown though. Any idea what could cause this?
Here are the sub-plugin changes I have so far:
Any hints are appreciated 👍
Hi @codeofsumit,
Indeed, you should remove the Marker from the MCG instead of from the map directly.
Or use Leaflet.FeatureGroup.SubGroup or Leaflet.MarkerCluster.LayerSupport.