Closed henrikmaa closed 3 years ago
Hi @henrikmaa,
I need to think about this a little when I have time.
Just to make sure I understand what you're after, you're looking to add freezing functionality directly to Leaflet.Deflate
and not to run Leaflet.MarkerCluster.Freezable
with Leaflet.Deflate
. Basically adding two methods to L.Deflate
:
freezeAtZoom
unfreeze
And out of curiosity, what is the use case for this?
Hi, not need to add freezing to Leaflet.deflate, my issue was that i did not get access to Leaflet.markerClusterGroup using Leaflet.Deflate. That prevented me to use the freezeAtZoom etc..
The reason I need this is because im editing a SINGLE object using leaflet-geoman. And when you are editing an object and perform a zoom (in or out) the markercluster fires some events to recluster, which then enables edit for ALL OBJECTS. I have managed to get that problem fixed using only leaflet markerCluster and not using Leaflet.Deflate, but now I cant get PolyLines to cluster. Making it possible to use the Leaflet.MarkerCluster Freezable with leaflet.Deflate would solve all my problems.
Hi @henrikmaa,
I've just published a beta that should make Leaflet.Deflate
work with Leaflet.MarkerCluster.Freezable
. It introduces layer injection, that means, you can now inject the layer used to display deflated features on the map, which allows you to control that layer outside of L.deflate
.
You can install the beta using npm install Leaflet.Deflate@next
There is an example for markercluster.freezable in the branch I'm working on.
You basically have to instantiate a L.markerClusterGroup
and then pass it as the markerLayer
option into L.deflate
:
var map = L.map("map").setView([51.550406, -0.140765], 16);
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
var layer = L.markerClusterGroup();
var features = L.deflate({minSize: 20, markerLayer: layer});
features.addTo(map);
// add all your features
layer.freezeAtZoom(15);
Let me know how this works for you. If this is ok, I can make a full release soon.
The changes have been released with 1.4.0. Closing the ticket.
Describe the solution you'd like A function to freeze the deflate at a certain zoom level. Preventing any updates to the deflating/clustering until you unlock the layers again.
Describe alternatives you've considered L.markercluster has a sub plugin for this: https://github.com/ghybs/Leaflet.MarkerCluster.Freezable I could not make it work because I could not get access to L.markerClusterGroup
Additional context https://ghybs.github.io/Leaflet.MarkerCluster.Freezable/examples/mcg-freezable.html?leaflet=1.3.1&leaflet.markercluster=1.3.0&leaflet.markercluster.freezable=1.0.0 freezeAtZoom()