GithubHelp home page GithubHelp logo

isabella232 / leaflet-knn Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mapbox/leaflet-knn

0.0 0.0 0.0 65 KB

k-next-nearest-neighbor searches for Leaflet

Home Page: http://mapbox.github.io/leaflet-knn/

License: BSD 2-Clause "Simplified" License

JavaScript 93.54% Makefile 1.34% HTML 5.11%

leaflet-knn's Introduction

leaflet-knn

Next-nearest neighbor searches with sphere-knn, with a Leaflet-friendly API.

example

var gj = L.geoJson(GEOJSON_DATA);
var nearest = leafletKnn(gj).nearest(L.latLng(38, -78), 5);

using it

wget https://raw.github.com/mapbox/leaflet-knn/master/leaflet-knn.min.js

(or without the .min. if you want more debugging power)

With browserify

npm install leaflet-knn

api

var index = leafletKnn(layer)

Generates a lookup function from an L.geoJson layer object.

API is the same as the sphere-knn API for the lookup function, but with nice handling for l.latLng

index.nearest(point: L.LatLng or [lon, lat], n, max_distance)

Given a point, find the nearest points to it. If the index contains multi-point features, like lines, polygons, and so on, it returns points in those features and can return more than one point in each feature.

  • point: L.LatLng or [lon, lat], index, [max points: int], [max distance: number])`
  • n: the maximum number of points returned from the search
  • max_distance: maximum distance in meters

index.nearestLayer(point: L.LatLng or [lon, lat], n, max_distance)

Like nearest, except multiple matches in the same multi-point feature are collapsed, so the array returned has one result per layer.

  • point: L.LatLng or [lon, lat], index, [max points: int], [max distance: number])`
  • n: the maximum number of points returned from the search
  • max_distance: maximum distance in meters

leaflet-knn's People

Contributors

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.