Syed Muhammad Oan
Syed Muhammad Oan

Reputation: 697

Google places api not showing results for some places

Hello i am using simple google map places api to get near by atms for users. My client lives around new york and for some strange reason api shows zero results for that place, but works fine near me (pakistan) . I searched for it a little and found out it was google's issue and some other places were also experiencing the same problem. But i never quite found any solution for this. This is the get call i use

https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=40.7128,74.1059&radius=10000000&keyword=atm&key=MY_KEY

I would really appreciate the help. Thank you :)

Upvotes: 2

Views: 3148

Answers (2)

Harshil Kotecha
Harshil Kotecha

Reputation: 2896

Google place nearby search maximum 50,000 meters (31 miles) . if you try enter more than 50,000 it not work proper.

There is another way for find all ATM in a city. google provide Text Search Requests

https://maps.googleapis.com/maps/api/place/textsearch/json?query=atm+in+Reno,NV,89501,USA&key={API_KEY}

query = keyword + in + city Name

for get city name using latitude longitude

http://maps.googleapis.com/maps/api/geocode/json?latlng=39.52963,-119.81380&sensor=true

For more information how to get city name using latitude longitude

https://developers.google.com/maps/documentation/geocoding/start?csw=1#ReverseGeocoding

for more information about how to use Text Search Requests

https://developers.google.com/places/web-service/search

OR (second way)

There is another way for find all ATM in a city.

  • Open Google Maps .
  • create 10-12 or more points latitude , longitude value to trigger request.
  • Then use a loop to find all places within these points.
  • If you want more appropriate results, increase first trigger points for your requests.

- It is just a logic i created in php.

$triggerPoints = array("lat1,long1", "lat2,long2", "lat3,long3",....);

    foreeach(triggerPoints as $tP){
       $requestUrl = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=$tP&radius=[YOUR_RADIUS_VALUE]&type=[YOUR_TYPE]&name=panera&key=[YOUR_KEY_HERE";
       $results = file_get_contents($requestUrl);
       //Do what you want with response JSON data

    }

Upvotes: 1

necip
necip

Reputation: 353

SHORT ANSWER: Use logical types with your needs.

In my case i used food types instead of supermarket. In some cases, my local market named A101 wasnt found under supermarkets. To find which keywords is best for you, you can search below url with your location and map_key and find most common keywords under types for each query and use it.

https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=40.986527896166244,%2029.24326049097467&rankby=distance&keyword=a101&key=YOUR_MAP_KEY

Upvotes: 0

Related Questions