Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nearestjs

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nearestjs

Utility library for calculating the nearest set of things to a target thing, geospatially speaking

  • 0.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Nearest.js

Nearest.js is a small utility library for calculating the nearest set of things to a target thing, geospatially speaking. In JavaScript.

Demo

For example, a list of restaurant reviews near to where you work,

API

Include in your page,

<script src="nearest.js"></script>

... and the Nearest.find function will return the items in that list sorted approximately in order of the distance from a given coordinate.

results = new Nearest().find(dataSource, {
   coords: [51.5349, -0.1219],
   limit: 10, 
   within: 3
})

The parameters in full,

  • dataSource - a data structure as per the format outline below.
  • coords - the lat/lon pair of the central location you want the search to start from.
  • limit - limit the number of results returned.
  • within - limit results to within n kilometers.

Data

Nearest.js requires a datasource containing a list of objects, each containing a lat and lon property.

  [
    {
        "path": "lifeandstyle/2012/jan/08/jay-rayner-restaurant-review-create",
        "restaurant": "Create",
        "reviewer": "John Lanchester",
        "lat": "53.797331",
        "lon": "-1.549829"
    },
    {
        "path": "lifeandstyle/2012/jan/06/granger-and-co-restaurant-review",
        "reviewer": "John Lanchester",
        "lat": "51.514502",
        "lon": "-0.198357",
        "links": [
            "foo": "http://example.com/foo",
            "bar": "http://example.com/bar"
        ]
    }
    ...
  ]

Keywords

FAQs

Package last updated on 30 Jan 2014

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