place-lookup
A lightweight Node.js module to get the latitude and longitude for any fuzzy place name using the Google Places API
Install
npm install place-lookup --save
Usage
var placeLookup = require('place-lookup');
var apiKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
placeLookup("oxford", apiKey, function(result){
console.log(result)
});
Results
{
place_name: 'Paris, France',
location: { lat: 48.856614, lng: 2.3522219 }
}
How to get yourself a Google Places API key
- Head over to The Google Developer Console
- In the top-left corner select "New Project" from the projects dropdown.
- In the API's menu, search for "Google Places API Web Service" and ensure it is set to enabled
- On the Credentials pags: Add Credential --> Server Key --> Give it a name, (leave IP blank if your unsure). Click create
- The 40-ish digit alpha-numeric code is your new key :)
License
MIT (C) Alicia Sykes