GithubHelp home page GithubHelp logo

isabella232 / leaflet-pip Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mapbox/leaflet-pip

0.0 0.0 0.0 164 KB

point in polygon intersections for leaflet

Home Page: https://mapbox.github.io/leaflet-pip/

License: BSD 2-Clause "Simplified" License

JavaScript 94.21% HTML 5.79%

leaflet-pip's Introduction

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 @mapbox/leaflet-pip

Resolve for a CDN/packaged version:

https://unpkg.com/@mapbox/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.

leaflet-pip's People

Contributors

codebling avatar jfirebaugh avatar tmcw avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.