How to search multiple locations by one query in google places api

I want to get some specific places using google places search api next to search. What is the format for requesting multiple locations with the NAME parameter. The api shows the following for one location:

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

      

I read in the documentation that you can specify multiple types by adding |.

How to specify multiple name parameters in closest google site search api?

+3


source to share


2 answers


If you want to use multiple types for searches, use the bitwise OR operator. See the last line of the append where I used 3 different types. Here's an example



private String getUrl(){

    StringBuilder sb = new StringBuilder("https://maps.googleapis.com/maps/api/place/nearbysearch/json?");
    if(mLastLocation != null){
        sb.append("location=" + mLastLocation.getLatitude() + "," + mLastLocation.getLongitude());
    }
    sb.append("&radius=" + searchWithin);
    sb.append("&sensor=true");
    sb.append("&key=" + getString(R.string.map_api_key));
    sb.append("&types=" + "restaurant|atm|bank");

    return sb.toString();
}

      

0


source


You must specify different names in the "name" field of your query variable. Separate Them | and is surrounded by quotes.

var request = {
  location: new google.maps.LatLng(-33.8665433,151.1956316),
  radius: '500',
  name: "name1|name2|name3",
  types: ['store']
};

service = new google.maps.places.PlacesService(map);
service.nearbySearch(request, callback);

      



https://developers.google.com/maps/documentation/javascript/places#place_search_requests

-1


source







All Articles