I am trying to build an application in which I need to retrieve location's type based on latitude and longitude. I tried using google's places API but not getting satisfied results.
For eg, if I want to know if the user searches for SFSU, it should be stored as 'university'. I can get its latitude/longitude from geocoding APIs.
https://maps.googleapis.com/maps/api/geocode/json?address=SFSU&key=YOUR_KEY
But from places API, I cannot get the exact type, I mostly get it as street or establishment:
https://maps.googleapis.com/maps/api/geocode/json?latlng=37.7244047,-122.4760196&key=YOUR_KEY
Similarly, I wanted to get cafe for any starbucks or mall/shopping-center for any mall.
Edit:
I got confused between geocode API and places API as geocode API also returns place' type. I found that places API returns multiple results even if we provide correct latitude and longitude. So if we need the perfect result, we need to provide sort filter with Places API.
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=(lat),(long)&rankby=distance&key=YOUR_API_KEY
It looks like you are using reverse geocoding, not the Places API.
Request to Places API should be something like:
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=37.7244047%2C-122.4760196&radius=10&type=university&key=YOUR_API_KEY
This one returns 'San Francisco State University, 1600 Holloway Avenue, San Francisco'
https://developers.google.com/places/web-service/search#PlaceSearchRequests
Hope it helps!
1.4m articles
1.4m replys
5 comments
57.0k users