Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Places API can't find places by name

I have an application that uses the places API to help find places near destinations (like London). I prefer using nearby because it allows me to focus on one area, and it's also cheaper compared to text searches.

Unfortunately, I get answers that don't make a lot of sense. As an example, if I search for:

name=London Eye

I get zero results (with or without quotes around it).

But if I search by keyword:

keyword=ferris wheel

London Eye is returned. Here are the relevant queries:

  • https://maps.googleapis.com/maps/api/place/nearbysearch/json?key=[API_KEY]&sensor=false&location=51.52864165,-0.10179430&radius=47022&name=%22london%20eye%22
  • https://maps.googleapis.com/maps/api/place/nearbysearch/json?key=[API_KEY]&sensor=false&location=51.52864165,-0.10179430&radius=47022&keyword=ferris%20wheel

Is there some rhyme or reason to this?

like image 426
Ken Anderson Avatar asked Aug 27 '13 20:08

Ken Anderson


People also ask

Why Google Places API is not working?

It looks like you try to use Web Service, not Places API for Android. In this case you cannot apply an API key with Android app restriction. Web Service requires a different API key. You can generate the new one, the only restriction that you can use with web services is by IP.

How do I get my city name from places API?

2) Make another web-service call to https://maps.googleapis.com/maps/api/place/details/json?key=API_KEY&placeid=place_id_retrieved_in_step_1. This will return a JSON which contains address_components . Looping through the types to find locality and postal_code can give you the city name and postal code.

How do I get a Google Places API number?

Currently, there is no way to get phone number from the Places API search response. In order to get a phone number you have to execute a Places details request for each individual place ID.


1 Answers

Well, issue is that you are using the wrong parameter.

Check the documentation and you'll see that parameter you should be using is keyword instead of name

It will be then:

https://maps.googleapis.com/maps/api/place/nearbysearch/json?key=[API_KEY]&sensor=false&location=51.52864165,-0.10179430&radius=47022&keyword=%22london%20eye%22

And that's working for me!

EDIT:

As I said, if you try:

https://maps.googleapis.com/maps/api/place/nearbysearch/json?key=[API_KEY]&sensor=false&location=51.52864165,-0.10179430&radius=47022&keyword=%22london%20eye%22&name=%22london%20eye%22

You get as return a lot of results better than using those parameters alone.

UPDATE

As of 2018 the name parameter was deprecated in favor of the keyword parameter, so from now on it is recommended to use only keyword parameter in your requests.

The documentation currently reads

name — A term to be matched against all content that Google has indexed for this place. Equivalent to keyword. The name field is no longer restricted to place names. Values in this field are combined with values in the keyword field and passed as part of the same search string. We recommend using only the keyword parameter for all search terms.

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

like image 84
unmultimedio Avatar answered Sep 17 '22 22:09

unmultimedio