🌐 getcoords
Get lat and long coordinates from any address
getcoords
uses the Google Geocoding API to convert any address into geographic coordinates.
Install
$ npm install getcoords
API Key
In order to use the package, you must first obtain a Google API key. Please visit the dev docs for instruction on how to obtain the key.
Then, you must set process.env.GOOGLE_GEOCOORDS_API_KEY
in your project using dotenv or similar. You could also set it globally in your shell (more info).
If you want to use it on client builds (such as in a React app) you will need to use dotenv-webpack.
Usage
// .envGOOGLE_GEOCOORDS_API_KEY=YOURKEYHERE
// app.js // Import the package; // Load your .env file; // Promise syntax ; // Or use with Async/await!async { try const latlng = await ; console; catch error console; }; //=> { lat: 34.1022444, lng: -118.3401679 }
Related
License
MIT © Melanie Seltzer