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

v0.3.1

Published

Leaflet plugin for uncluttering L.Markers using basic collision detection.

Downloads

271

Readme

Leaflet.LayerGroup.Collision

Provides basic collision detection in order to declutter large or overlapping sets of Leaflet markers.

Don't like READMEs? Then see http://mazemap.github.io/Leaflet.LayerGroup.Collision/demo/demo.html

What?

Inspired by the ClusterMarker plugin, this plugin works by hiding any markers that overlap each other - only the marker which was first added to the LayerGroup will be shown.

How?

Collision detection is done by using the dimensions of the DOM elements inside the L.Marker's icon; this has been tested only using display:block elements. L.Layers which are not markers will be always shown.

This plugin uses Vladimir Agafonkin's rbush library for the grunt work of detecting bounding box collisions.

Caveats: this plugin expects markers to not change dinamically, to not be draggable, and marker deletion is not supported (yet). Currently everything is recalculated on zoom change. Only partial data caching is done - marker bounding boxes are cached; collisions per zoom level are recalculated.

Usage

Works as a normal Leaflet LayerGroup, just add your markers to it.

When instantiating, can take the 'margin' option. This defines the margin between markers, in pixels, and defaults to zero.

var collisionLayer = L.layerGroup.collision({margin:5});
collisionLayer.addTo(map);

collisionLayer.add( L.marker( markeroptions ) );

This plugin also extends L.FeatureGroup into L.FeatureGroup.collision and L.GeoJSON into L.GeoJSON.collision.

Demo

There is a live demo at http://mazemap.github.io/Leaflet.LayerGroup.Collision/demo/demo.html

The demo loads about 1000 placenames, each of them being a L.DivIcon with two boxes.

The demo includes data from Natural Earth, which is public domain. Please visit http://www.naturalearthdata.com/downloads/10m-cultural-vectors/10m-populated-places/ for more information.

In order to try the demo locally, just clone the repo, run bower install (if using the gh-pages branch, use git clone --recursive instead to pull the rbush submodule), and see the file demo/demo.html. You can choose to load more or less data by commenting/uncommenting the lines that include the natural earth data files.