How can I search places with specific types using Google Places API?
Asked Answered
B

1

8

I am using google place api to search specific types like(gas_station,cafes,shopping_malls etc...) here is link i am using https://maps.googleapis.com/maps/api/place/search/json?location=41.104805,29.024291&radius=50000&types=gas_station&sensor=false&key=AIzaSyAhVKOOLN1lx6iKKnbXMT82W1cKG7O8cDY

so here i need to search all gas_stations nearby my location so here i get "

results" : [],
   "status" : "ZERO_RESULTS"

But in my location some gas_stations are there(i search google map) so how can i get these results can any one help me..

Thanks for advance.

Britain answered 28/12, 2011 at 6:16 Comment(0)
H
14

The problem is with the categorization of the data. If you do a search for types=university you'll see a number of results. Now look at the types in those results - they're listed mostly as ["university", "establishment"].

All of the gas stations in the area are only categorized as ["establishment"], so they're not coming up in your search for gas_station.

You could use the keyword search to return businesses with "gas%20station" in their metadata. It seems to return the same results as searching for "gas station" around that area in Google Maps.

Hyperaesthesia answered 28/12, 2011 at 15:34 Comment(5)
thanks for your response i tried type establishment also i get 20 locations but in this there is no gas_stationsBritain
It seems that the gas stations aren't categorized beyond 'establishment'. I'd suggest not using the type parameter for this particular search, and just using keyword=gas%20station. That'll give you the same (or very similar) results as when you search for 'gas station' on Google Maps in the same area.Hyperaesthesia
thanks mike...it's working so i need some more type like cafes, shopping_malls so can i write this keyword=gas%20station|cafes|shopping%20malls ?how can increment locations count i get only 20 can i increment this count?Britain
As far as I know, there's no way to do 'OR' searches like that with the keyword field. You could search for all of the terms, but they'd be returned as a group with no way to differentiate between each type. You're better to run multiple Place searches, if you need to keep track of categories. Re: getting more than 20 results, there's no documented start or page parameter that would suggest the ability to retrieve further results.Hyperaesthesia
This google apis return the places in sets of 20, the maximum number of places that an api can fetch is 60. If you carefully observe the response of the google places api, it has a parameter called next_pagetoken. So the second time you hit the API u need to pass this next_pagetoken to fetch the next set of schools.@ChithriAjayRecreate

© 2022 - 2024 — McMap. All rights reserved.