Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google place api: Place Search filter by country

I'm working on Google Place API with Text Search Requests and I'm wondering how to filter results for a specific country. Is there a way?

What I'm trying to do is call the api with results filtered by country and then manage the json result with php.

So, this is a kind of query

https://maps.googleapis.com/maps/api/place/textsearch/json?query=pizza&sensor=true&key=mykey

I wish to add a parameter like &country=us, but it seems it doesn't exists.

Thanks

like image 330
Luca Avatar asked Jan 01 '15 15:01

Luca


People also ask

How do I use Google Places API for location analysis and more?

Once you've made an account and are on the Google Cloud platform, you'll want to go to use the drop down navigation in the top left and choose API & Services > Credentials. Once there, you'll want to hit Create Credentials on the top followed by API key.

How do I restrict Google Places API?

You can restrict results from a Place Autocomplete request to be of a certain type by passing the types parameter. This parameter specifies a type or a type collection, as listed in Place Types. If nothing is specified, all types are returned.


1 Answers

Google maps platform provide parameter region for next search types :

  • Text search
  • Place Details

So, enjoy your pizza in United Arab Emirates: https://maps.googleapis.com/maps/api/place/textsearch/json?query=pizza&region=ae&key=mykey

Please pay attention that this "region" parameter should be from: country top-level domains.

Most ccTLD codes are identical to ISO 3166-1 codes, with some notable exceptions

like image 125
Volodymyr Drozd Avatar answered Nov 02 '22 06:11

Volodymyr Drozd