city-to-coordsdeprecated

Enter city, get coordinates

Usage no npm install needed!

<script type="module">
  import cityToCoords from 'https://cdn.skypack.dev/city-to-coords';
</script>

README

city-to-coords

Enter a city, get coordinates

js-semistandard-style

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 node 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);
  });

Where coords is:

{
  lat: '40.782',
  lng: '-73.832'
}