Skip to content

iwharrison/leaflet-knn

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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/tmcw/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)

  • 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

About

k-next-nearest-neighbor searches for Leaflet

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published