city-to-coords
Enter a city, get coordinates
I wanted a simple way to get coordinates from a given location,
and weather-js actually gives good coordinates
quickly, so I decided to use that.
Please note that this requires version 0.12 or higher.
Usage
Requiring the module and you will get a function which takes a city (or really, any location)
and returns a promise with the latitude and longitude in an object, or an error.
import getCoords from 'city-to-coords';
getCoords('NYC')
.then((coords) => {
console.log(coords);
});
coords
is:
{
lat: '40.782',
lng: '-73.832'
}