Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Places API bounds in http request

Is it possible to limit the search area for Google Places in an http request? The website mentions bounds are possible (using SW and NE lat and long for the corners) for the javascript method but I would like to stick to the http request because I know nothing about javascript. Any help would be really appreciated because I am struggling with this. Thank you!

like image 794
user2125844 Avatar asked Aug 27 '26 10:08

user2125844


1 Answers

So, your http request should be something similar to this:

https://maps.googleapis.com/maps/api/place/nearbysearch/output?parameters

There are a required set of parameters, including the radius parameter (unless rankby=distance is set) that need to be used with the places api. The radius parameter is what you are looking for, the maximum allowed value is 50,000. The units are in meters, so the maximum distance would be 50km.

An example http api call would look something like this:

https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&radius=500&types=food&name=harbour&sensor=false&key=AddYourOwnKeyHere

This will output the requested places of type 'food' within a 500m radius of a point in Sydney, Australia, containing the word 'harbour' in their name. The data will be returned in the Json format. You may be working with XML data instead of Json, if that's the case then just replace json with xml in the http request.

More information on using the Places API can be found Here.

like image 108
David Freitag Avatar answered Aug 30 '26 08:08

David Freitag



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!