Reputation: 87
I have this document in my collection inside a db in MongoDB
{
name: "steve",
id: 11,
address: "24 rue Victor Hugo"
geolocation:
{latitude:"16.66667",longitude:"101.18333"}
}
I want to get the city name from the geolocation data, I am working in Vs with node, express and mongoose. I tried to find a way to do without manipulating my db, because I already have my collection set before starting.
Upvotes: 0
Views: 369
Reputation: 408
What you are trying to do is called reverse geocoding. It is available through the Google Maps Geocoding API. You have to sign up for a Google Developers account. Afterwards, you create a project from the Google Developers console. You can then request an API key. You can then use this API key in your request to the Google Maps API as follows:
https://maps.googleapis.com/maps/api/geocode/json?latlng=16.66667,101.18333&key=YOUR_API_KEY
Take a look at Google's Goecoding API documentation here. You can also test that URL in a browser to see the returned JSON-result, or using curl from the command-line.
Upvotes: 1
Reputation: 19
You can make requests with your geolocation parameters for address information.
https://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&key=YOUR_API_KEY
Upvotes: 2