find-nearest-us-cities

0.3.6 • Public • Published

find-nearest-us-cities

Searches the nearest cities in The United States using geokdbush. Data courtesy US at geonames.org. Based on find-nearest-cities

Installing

npm install find-nearest-us-cities

Usage

const nearestCities = require('find-nearest-us-cities')

// The Rocky Statue
const latitude = 39.9649;
const longitude = -75.1802;

const cities = nearestCities(latitude, longitude);

/*
[ { 
    name: 'Fairmount',
    lat: 39.97233,
    lon: -75.18101,
    state: 'PA'
  },
  { name: 'Brewerytown',
    lat: 39.97706,
    lon: -75.18185,
    state: 'PA' },
  { name: 'Strawberry Mansion',
    lat: 39.98345,
    lon: -75.18268,
    state: 'PA' },
  { name: 'S.W. Ctr Cty',
    lat: 39.94281,
    lon: -75.18086,
    state: 'PA' },
  { name: 'Point Breeze',
    lat: 39.93345,
    lon: -75.17796,
    state: 'PA' }
]
*/

API

nearestCities(longitude, latitude[, maxDistance, maxResults])

Returns an array of the closest points from a given location in order of increasing distance.

  • longitude: query point longitude.
  • latitude: query point latitude.
  • maxDistance: (optional) maximum distance in meters to search within (Infinity by default).
  • maxResults: (optional) maximum number of points to return (5 by default).

Data License

The Dataset is published under Creative Commons Attribution 4.0 International by geonames.org.

Readme

Keywords

none

Package Sidebar

Install

npm i find-nearest-us-cities

Weekly Downloads

40

Version

0.3.6

License

MIT

Unpacked Size

7.36 MB

Total Files

9

Last publish

Collaborators

  • jmealo