Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/motleyagency/find-lat-lng
Finds latitude and longitude for an array of street names.
https://github.com/motleyagency/find-lat-lng
Last synced: about 1 month ago
JSON representation
Finds latitude and longitude for an array of street names.
- Host: GitHub
- URL: https://github.com/motleyagency/find-lat-lng
- Owner: motleyagency
- License: mit
- Created: 2018-01-26T15:46:12.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-09T08:22:14.000Z (about 2 years ago)
- Last Synced: 2024-10-11T01:38:51.836Z (4 months ago)
- Language: JavaScript
- Size: 643 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# find-lat-lng [![Build Status](https://travis-ci.org/motleyagency/find-lat-lng.svg?branch=master)](https://travis-ci.org/motleyagency/find-lat-lng)
Finds latitude and longitude for an array of street names.
## Install
```
$ npm install --save find-lat-lng# or with yarn
$ yarn add find-lat-lng
```## Usage
```js
import findLatLong from 'find-lat-lng';const GOOGLE_API_KEY = 'your_google_api_key'; // (https://developers.google.com/maps/documentation/javascript/get-api-key)
const client = findLatLng(GOOGLE_API_KEY);
const items = ["Lönnrotinkatu 5, Helsinki", "Lönnrotinkatu 4, Helsinki"];(async () => {
const itemsWithLatLng = await client(items, { debug: false });
console.log(itemsWithLatLng);/*
[
{ address: 'Lonnrotinkatu 5', lat: 60.166924, lng: 24.939788},
{ address: 'Lonnrotinkatu 4', lat: 60.167142, lng: 24.940959},
...
]
*/
})();
```If lat and/or lng is not found `null` is returned
## API
### findLatLng(GOOGLE_API_KEY)(items [,options])
`findLatLng` must be initialized with your Google Maps API Key. After calling the initialized client it
returns a promise for an array of `address, lat, lng` objects.Items must be an array of addresses to search for.
#### Options
Type: `Object`
default: {`debug: false`}Object of optional options.
##### debug
Type: `Boolean`
default: `false`If true, `console.warn`s about lat/lngs that were not found.
## CLI
See [find-lat-lng-cli](https://github.com/motleyagency/find-lat-lng-cli) for a CLI for this module
## Related
- [find-lat-lng-cli](https://github.com/motleyagency/find-lat-lng-cli) - Make a directory and its parents if needed
## License
MIT © Pete Nykänen