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

v0.2.2

Published

Leafet heatmap that provides binning of values using formally defined grid cells

Downloads

12

Readme

leaflet-heatbin

ALPHA plugin for heatmap.js to add heatmaps to leaflet.

what?

This is an enhanced version of leaflet-heatmap that provides greater control over how data points are grouped to create a heatmap.

why?

Most heatmaps provide little control over how data is grouped beyond a pixel radius.

For many use-cases that is not enough - we often need to know exactly what data is in each cluster.

how?

This plugin provides two ways of doing this better, you can either:

  1. Define the radius in meters instead of pixels; and/or
  2. Define a grid of cells which are used for value binning.

cell binning example

// define options
const options = {
  heatBin: {
    enabled:     true,
    cellSizeKm:  0.25, // e.g. bin values into 250m grid cells
    maxFactor:   0.8,  // heatmap max value will be multiplied by maxFactor
    showBinGrid: false // a debugging option, plots the binning grid on the map*
    staticMax:   100   // define a fixed number to use for scale max, default false
    minThreshold: 10   // ignore heatbin cells below this value, default false
  },
  // plus any options from heatmap.js core
  radius: 20,
  useLocalExtrema: true,
  onExtremaChange: function(data) {
    console.log(data);
  },
  pane: 'myCustomPane' // name of an existing leaflet pane to add the layer to, default: 'overlayPane'
};
const layer = L.heatBin(options);
layer.setData(myData);

meter radius example

// define options
const options = {
  fixedRadius: true,
  radiusMeters: 100
};
const layer = L.heatBin(options);
layer.setData(myData);

data format

Essentially the same as vanilla heatmap.js, with the addition of an optional param: uid. When uid is specified and heatBin is enabled, a data point is only counted once per cell, per uid.

const points = [
  {
    lat:   '<lat>',
    lng:   '<lng>',
    value: 10,
    uid:   '<uid>' // optional
  }
]

install, use

npm install leaflet-heatbin --save

This plugin has external dependencies:

To use this plugin, you either need to:

  • load these dependencies yourself (prior to loading leaflet-heatbin); or
  • use the standalone version with dependencies bundled, in dist/leaflet-heatbin-standalone.js

public methods

|method|params|description| |---|---|---| |isActive||check if the particle layer is currently active on the map| |setData|data: {Object}|update the layer with new data object| |update||update the layer/trigger redraw| |getLatLngBounds|data: {Object}, optional|Returns leaflet LatLngBounds of supplied, or layer data| |getGridInfo||Get information about the grid used for binning|

binning?

When binning is enabled, a grid of cells is generated using turf, which is then used to cluster data points by grid cell indices.

If you're interested to see how your data is being gridded, you can set the showBinGrid to true to see the grid at work:

Screenshot