New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

leaflet-pip

Package Overview
Dependencies
Maintainers
21
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

leaflet-pip

point in polygon searches for leaflet

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
854
decreased by-9.44%
Maintainers
21
Weekly downloads
 
Created
Source

point in polygon for Leaflet

build status

A Leaflet-friendly API for point in polygon operations, using substack's point in polygon library.

install

With browserify

npm install leaflet-pip

Resolve for a CDN/packaged version:

https://unpkg.com/leaflet-pip@latest/leaflet-pip.js

example

var gjLayer = L.geoJson(statesData);
var results = leafletPip.pointInLayer([-88, 38], gjLayer);
// results is an array of L.Polygon objects containing that point

api

leafletPip.pointInLayer(point, layer L.GeoJSON, [first])

Point can be:

  • A two-element array of [lng, lat]
  • A L.LatLng object

Layer must be:

  • A L.geoJSON layer

first can be:

  • boolean: true to accept the first match, or false to return all polygons containing this point. This can be useful if you know that your polygons are non-overlapping or don't care about more than one result, since it will be much faster. By default, this is false and all matches are returned.

Returns:

An array of polygons in which the given point resides, an empty array if there are none. The polygons are returned as direct sublayers, so they can include MultiPolygons. You can call pointInLayer again on those if you want the sub-polygon result.

leafletPip.bassackwards

Leaflet treats literate coordinate arrays as [lat, lon], unlike GeoJSON and any true scotsman. leaflet-pip treats literate coordinate arrays as [lon, lat], but if you set bassackwards to true, it'll do things the Leaflet/Google Maps API way.

Keywords

FAQs

Package last updated on 22 Nov 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc