Google Maps API - Multiple Keyword Search

Can I search for multiple individual keywords in a single search using the Google Maps JavaScript API v3?

The Google Places API documentation says that you can use several keywords https://developers.google.com/places/training/additional-places-features.

?keyword=theater+gym

but this does not work in the JavaScript API. I did my best:

 function performSearch() { var request = { location: map.center, radius: '500', keyword: 'theater+gym+tacos', rankBy: 'distance' }; service.radarSearch(request, callback); } 

... and doesn’t return space for each keyword. Anyone have any ideas how to search for multiple keywords?

Note. I am trying to find several separate keywords in a single query, not a phrase with spaces.

+7
source share
6 answers

It seems like the answer is no (at least at the moment you can request an extension in the problem tracker .

The work around will be to send three separate requests, one for each keyword. It should be OK for 3 keywords, at some point you will come across a query speed limit.

  var request = { location: pyrmont, radius: 500, keyword: 'theater' }; infowindow = new google.maps.InfoWindow(); var service = new google.maps.places.PlacesService(map); service.nearbySearch(request, callback); var request2 = { location: pyrmont, radius: 500, keyword: 'gym' }; var service2 = new google.maps.places.PlacesService(map); service2.nearbySearch(request2, callback); var request3 = { location: pyrmont, radius: 500, keyword: 'tacos' }; var service3 = new google.maps.places.PlacesService(map); service3.nearbySearch(request2, callback); 

proof of concept

+10
source

Using the Google place API, a boolean search is as follows:

 var request = { location: /*your location*/, radius: /*your radius*/, keyword: "(cinema) OR (theater)" }; 

You can use OR, and respect the cause !!

+7
source

EDIT: This seemed to work initially, but more results were not reliable and were not predictable. As a result, we were not able to use the API in this way for our scenario.

I am using a web service, but I assume that it should work with all API access points. It took me a lot of combinations for testing, but I eventually landed on the implementation of the required API brackets and quotes to get the plural word conditions OR.

For example, in the url param form:

keywords = ("Place Name 1") OR ("PlaceName2") OR ("Place Name3")

+3
source

I had the same problem when I was trying to figure out how to use multiple keywords in a single query. At first, @netoale's answer helped me, but that is no longer possible. After some general problems with Google, I asked the support team, and one of the employees wrote to me that you can associate several keywords with a simple "|".

As an example:

 https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=lat,lng&key=API_KEY&keyword=theater|castle|park&rankby=distance 

It works for me now.

+3
source

Have you tried with type parameter. If you use a type, you can get more than one place.

Please see the possible supported types and try RadarSearchRequests like this

 function performSearch() { var request = { location: map.center, radius: '500', types: ['movie_theater', 'gym'], rankBy: 'distance' }; service.radarSearch(request, callback); } 

I do not know what type of tacos. please support type and give value to type tacos.

Please let me know if you have any problems.

+1
source

I believe this is due to Open Problem 4845 of the Google Maps API . Please flag this issue to track progress.

0
source

Source: https://habr.com/ru/post/956838/


All Articles