user3575965
user3575965

Reputation: 29

How can I search places with 2 specific types using Google Places API?

return "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location="
            +lat+','+lng
            + "&radius=" +radius
            + "&types=" + "food,hospital" //???
            + "&type=point_of_interest&key=KEY";

How can I get all hospitals and food near by me? I use ""&types=" + "food,hospital", but this gives me all types of places near me.

Thank you for your answers.

Upvotes: 0

Views: 194

Answers (1)

rafsanahmad007
rafsanahmad007

Reputation: 23881

Try using:

String types = "food|hospital"; -- the pipe symbol

in code:

String URL = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=";
String types = "food|hospital";
String key = "your_key";
try {
      placesSearchStr = URL +lat+ "," +lng+
                        "&radius=1000&sensor=false&types="+URLEncoder.encode(types,"UTF-8")+
                        "&key="+key;
      return placesSearchStr;
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }

Upvotes: 1

Related Questions