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

v3.0.0

Published

Find features from a point using Mapbox Vector Tiles data

Downloads

22

Readme

Leaflet Underneath

NPM version Leaflet 1.0 compatible!

Check out the demo

With a normal tile layer, the user can't interact to find out more about a location, since it is a static image. With this plugin, you can find out what features are underneath the current mouse position, for example when the user clicks the map.

This is done using Mapbox Vector Tiles, that are queried for features in a way that is both fast and reasonably bandwidth efficient.

Leaflet 1.0 compatibility

Version 3.0 and up of Leaflet Underneath is only compatible with Leaflet 1.0; earlier versions only work with Leaflet 0.7.

Using

Download the code. Include the pre-built Leaflet Underneath script in your project:

    <script src="leaflet-underneath/dist/leaflet-underneath.js"></script>

or, even better, use Browserify or similar and install from npm:

npm install --save leaflet-underneath
var L = require('leaflet');
require('leaflet-underneath');

// Leaflet Underneath will be available as L.underneath

For a complete example on how to use Leaflet Underneath, see basic Leaflet Underneath example.

API

L.Underneath

Leaflet Underneath can be queried for features from a location.

Creation

Factory | Description ---------------------|----------------------------- L.underneath(<String> tileUrl, <Map> map, <UnderneathOptions`> options?) | Instantiates a new Leaflet Underneath layer

Options

Option | Type | Default | Description -----------------------|---------------|----------------------|---------------------------- minZoom | Number | 0 | Minimum zoom level in the tile set maxZoom | Number | 22 | Maximum zoom level in the tile set subdomains | Array | ['a', 'b', 'c'] | Available subdomains layers | String[] | [] | Names of layers to include in search defaultRadius | Number | 20 | Default number of pixels search radius featureId | Function | | Function that returns a unique feature id; used to filter out duplicates. Default returns a features osm_idproperty zoomIn | Number | 0 | Zoom in relative to the map's current zoom level when making a query; used to get more or less detailed results than current zoom would give joinFeatures | Boolean | false | For features with same id, should geometries be joined (true), or should they be ignored (false)

Methods

Method | Returns | Description --------------------------------|---------------------------|-------------------------- query(<L.LatLng> latLng, <Function> callback, <Object> context, <QueryOptions> options?)|this| Asynchronously queries for features nearlatLng; callbackwill be called with features withinradius` pixels of the coordinate

QueryOptions

Option | Type | Default | Description -----------------------|---------------|----------------------|---------------------------- radius | Number | Take from layer options | Number of pixels search radius onlyInside | Boolean | false | Only return features (polygons) that the queried location is inside