npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

leaflet.markercluster.freezable.keeprock

v0.1.1

Published

Sub-plugin for Leaflet.markercluster plugin; adds the ability to freeze clusters at a specified zoom.

Downloads

19

Readme

Leaflet.MarkerCluster.Freezable

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.

GitHub releases npm

Requirements

This plugin should be compatible with both combinations:

  • Leaflet 1.0.x + Leaflet.markercluster 1.0.0
  • Leaflet legacy (0.7.x) + Leaflet.markercluster legacy (0.5.x)

Demos

Usage instructions

Quick Guide

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.

Installing the sub-plugin

Local copy

  1. Download the "leaflet.markercluster.freezable.js" file from the v0.1.1 release.
  2. Place the file alongside your page.
  3. Add the script tag (see Quick Guide > HTML) to your page after Leaflet and Leaflet.markercluster scripts.

CDN

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/[email protected]/dist/leaflet.markercluster.freezable.js"></script>

Creation

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);

API Reference

Methods

| 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.

Regular MCG options, events and methods

All regular MCG options, events and methods are available within MCG Layer Support. Refer to Leaflet.markercluster documentation.

Limitations

Freezing at current zoom while not on map

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.

License

license

Leaflet.MarkerCluster.Freezable is distributed under the MIT License (Expat type), like Leaflet.markercluster.