Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/soroushchehresa/map-nearest-location
📍 Find the nearest location and get distance from locations list without network request
https://github.com/soroushchehresa/map-nearest-location
distance google-maps javascript-map map maps npm-package offline-maps
Last synced: 3 months ago
JSON representation
📍 Find the nearest location and get distance from locations list without network request
- Host: GitHub
- URL: https://github.com/soroushchehresa/map-nearest-location
- Owner: soroushchehresa
- License: mit
- Created: 2017-11-09T15:25:23.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-03-03T22:28:05.000Z (almost 2 years ago)
- Last Synced: 2024-11-10T01:34:57.501Z (3 months ago)
- Topics: distance, google-maps, javascript-map, map, maps, npm-package, offline-maps
- Language: JavaScript
- Homepage:
- Size: 29.3 KB
- Stars: 16
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# map-nearest-location [![NPM](https://img.shields.io/npm/v/map-nearest-location.svg)](https://www.npmjs.com/package/map-nearest-location)
Simple library to find the nearest location and get distance from locations list without network request.
## Install
`npm i -S map-nearest-location`
or
`yarn add map-nearest-location`
## Usage
```
import findNearestLocation from 'map-nearest-location';
const myLocation = {
lat: 40.7153043,
lng: -74.1037503
};const locations = [
{
lat: 40.7722691,
lng: -74.3008176
},
{
lat: 40.682638,
lng: -73.941015
},
{
lat: 40.870347,
lng: -74.105810
},
{
lat: 40.7374197,
lng: -74.2719785
}
];const nearestLocation = findNearestLocation(myLocation, locations);
```
## Output
```
{
location: {
lat: 40.682638,
lng: -73.941015
},
distance: 14191.625245346084 // meter
}```