![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
leaflet.markercluster.freezable
Advanced tools
Sub-plugin for Leaflet.markercluster plugin; adds the ability to freeze clusters at a specified zoom.
Sub-plugin for Leaflet.markercluster plugin (MCG in short); adds the ability to freeze clusters at a specified zoom.
Leaflet.markercluster plugin provides beautiful animated Marker Clustering functionality.
Leaflet is the leading open-source JavaScript library for mobile-friendly interactive maps.
This plugin is compatible with the following combinations:
Leaflet | Leaflet.markercluster | Leaflet.MarkerCluster.Freezable |
---|---|---|
1.0.0 → 1.2.0 | 1.0.4 → 1.1.0 | 1.0.0 |
1.0.0 → 1.0.3 | 0.1.1 | |
0.7.7 | 0.5.0 |
HTML:
<!-- After Leaflet and Leaflet.markercluster scripts -->
<script src="leaflet.markercluster.freezable.js"></script>
JavaScript:
var map = L.map("map"),
mcg = L.markerClusterGroup(options);
mcg.addLayers(arrayOfMarkers);
mcg.addTo(map);
mcg.freezeAtZoom(15);
mcg.freezeAtZoom("maxKeepSpiderfy");
mcg.freezeAtZoom("max");
mcg.unfreeze(); // shortcut for mcg.freezeAtZoom(false)
mcg.disableClusteringKeepSpiderfy(); // shortcut for mcg.freezeAtZoom("maxKeepSpiderfy")
mcg.disableClustering(); // shortcut for mcg.freezeAtZoom("max")
mcg.enableClustering(); // alias for mcg.unfreeze()
When frozen / disabled, clusters will no longer split / merge on map zoom, but retain their status as if they were on the specified zoom level. They will directly spiderfy when clicked on, instead of zooming to bounds (since zooming will not make them split apart).
In particular, freezing at maxZoom + 1
removes all clusters.
Freezing at maxZoom
removes all clusters except the bottom-most ones, so that
user can still spiderfy closely positioned markers.
CAUTION: make sure your operations makes sense before freezing to high zoom whereas the map is at a low zoom. It may have to load thousands of markers suddenly!
Note: while frozen, MCG will continue removing clusters and markers which are
far from the view port, accordingly with removeOutsideVisibleBounds
option.
leaflet.markercluster.freezable.js
" file from the v1.0.0
release.script
tag (see Quick Guide > HTML) to your page after Leaflet and Leaflet.markercluster scripts.You can alternatively use the free unpkg CDN service, but keep in mind that it "is a free, best-effort service and cannot provide any uptime or support guarantees".
<!-- After Leaflet script -->
<script src="https://unpkg.com/leaflet.markercluster.freezable@1.0.0/dist/leaflet.markercluster.freezable.js"></script>
Add this package to your project:
$ npm install leaflet.markercluster.freezable --save
If you are using a bundling tool, import in your JavaScript.
It only performs the side effect of adding new methods to L.markerClusterGroup
,
so you do not need to store it into a local variable or import a namespace.
require('leaflet.markercluster.freezable');
// Or with ES6:
import 'leaflet.markercluster.freezable';
Simply use the the regular L.markerClusterGroup
factory, as Freezable plugin
directly adds new methods to Leaflet.markercluster:
var mcg = L.markerClusterGroup(options);
mcg.addTo(map);
Method | Returns | Description |
---|---|---|
freezeAtZoom( <Number> or <String> or <Boolean> frozenZoom? ) | this | Freezes clusters at specified zoom, current zoom, or unfreeze. If passed a positive number (including 0), freezes at that zoom. If passed "max" (string), freezes at maxZoom + 1 . If passed "maxKeepSpiderfy" (string), freezes at maxZoom . If passed nothing, undefined , true (boolean) or NaN , freezes at current zoom. If passed false (boolean) or any other non-number, unfreezes. |
unfreeze() | this | Shortcut for freezeAtZoom(false) . |
disableClustering() | this | Shortcut for freezeAtZoom("max") . |
disableClusteringKeepSpiderfy() | this | Shortcut for freezeAtZoom("maxKeepSpiderfy") . |
enableClustering() | this | Shortcut for unfreeze() . |
MCG.Freezable does not provide any extra option or event.
All regular MCG options, events and methods are available within MCG Layer Support. Refer to Leaflet.markercluster documentation.
If you request MCG to freeze at current zoom, but MCG is not on any map at that moment, it will freeze at the zoom the map is at when added to it.
Leaflet.MarkerCluster.Freezable is distributed under the MIT License (Expat type), like Leaflet.markercluster.
1.0.0 (2017-10-27) for Leaflet 1.0 + MCG >= 1.0.4
Compatible with Leaflet >= 1.0.0 and Leaflet.markercluster >= 1.0.4
Breaking changes:
Fixes:
Docs:
dist
version, therefore obsoleting the debug
pages.gh-pages
branch to docs/
folder, so that online demo pages are easier to maintain #9FAQs
Sub-plugin for Leaflet.markercluster plugin; adds the ability to freeze clusters at a specified zoom.
The npm package leaflet.markercluster.freezable receives a total of 1,766 weekly downloads. As such, leaflet.markercluster.freezable popularity was classified as popular.
We found that leaflet.markercluster.freezable demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.