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-glify-layer

v0.0.6

Published

Add-on for the Leaflet.glify plugin to provide more leaflet-idiomatic bindings

Downloads

96

Readme

leaflet-glify-layer NPM version NPM Downloads

Add-on for the Leaflet.glify plugin to provide more leaflet-idiomatic bindings.

Together this provides fast webgl rendering for GeoJSON FeatureCollections (currently limited to polygons, lines and points).

wow, very data Screenshot

why use this plugin?

The leaflet-glify plugin is great 🙏🙏 but does not behave like a typical leaflet layer, e.g.

  • unlike the L.geoJSON layer, GeoJSON polygons/points/lines must be created and managed as separate layers, which can quickly become unmanageable
  • common functions like layer.addTo(map), map.removeLayer(layer) don't work 'the leaflet way'
  • polygons and points/lines have inconsistent coordinate ordering (GeoJSON convention is [lng,lat])
  • missing other convienience methods (e.g. layer.getBounds)
  • default styling is very inconsistent with leaflet

install

npm install leaflet-glify-layer --save

use

This plugin acts as an add-on for L.glify, to managing the various L.glify layers required if you provide mutiple geometry types, and providing other leaflet-iodomatic methods/bindings.

Most importantly - GeoJSON can either be provided as:

  1. A single FeatureCollection containing features of mixed geometry types
  • this is slower as features must be sorted into types; however
  • sorting uses web workers to avoid blocking main thread
  1. A FeatureCollection for each geometry type (faster)

Note: L.glify expects points as an array of coords rather than GeoJSON features, so for now - the full GeoJSON object/properties are lost.. 😞

const myLayer = L.glify.layer({
  
  // Option #1. A single GeoJSON FeatureCollection that needs to be sorted
  geojson: {},

  // Option #2. -> FeatureCollection's that are pre-sorted by type 
  type: { 
    shapes: {}, // FeatureCollection of Polygon's
    lines: {},  // FeatureCollection of LineString's
    points: {}, // FeatureCollection of Point's
  },
  // L.glify options - currently a single set
  // of options is used for all geometry types
  glifyOptions: {
    // defaults vaguely match leaflet
    border: true,
    opacity: 0.2,
    size: 10
  }

  // OPTIONAL - supply the name of a custom pane,
  // will be created if doesn't exist, defaults to overlayPane
  // (used by L.glify as `pane` option)
  // https://leafletjs.com/reference-1.6.0.html#map-pane
  paneName: "overlayPane",
  
  // OPTIONAL - callback to be notified when types 
  // have been sorted, L.glify will be created
  onTypesReady() {},

  // OPTIONAL - callbacks when layer is added/removed from map
  onAdd: function(){},
  onRemove: function(){},
});

myLayer.addToMap(map);

public methods

|method|params|description| |---|---|---| |setStyle|options: { color, border, opacity, size}|Updates style settings| |getBounds||Returns L.latLngBounds for the L.glify.layer| |render||Force re-render| |update|(data, index)|Calls update on L.glify layers| |remove|(index)|Calls remove on L.glify layers|

development

npm install 
npm run build

thanks

  • https://github.com/robertleeplummerjr/Leaflet.glify
  • http://bl.ocks.org/Sumbera/c6fed35c377a46ff74c3
  • https://github.com/mapbox/earcut