19

I am making certain android app that requires user to choose a place. I am planning to user google places API.Link: https://developers.google.com/places/android/

This API gives gives nice way to do so through through Place Picker. https://developers.google.com/places/android/placepicker

Now suppose I want to only show user places of food type (restaurant, hotel etc.) . Using Places Browser API this can be done by adding "type=restraunts" attribute in the requests.

Is there a way to show only places of certain types using the Google Places Picker for android ?

silent_grave
  • 628
  • 1
  • 7
  • 20
  • did you finally arrive at any solution for this ? I am stuck with same problem. – Ramesh Sep 07 '15 at 07:25
  • 1
    No I didn't. It is not possible through android API, I suppose. Google people in charge of this API don't care enough to respond. Maybe you should look at other Place APIs. Or work out a way with Browser API. – silent_grave Sep 07 '15 at 16:56
  • There is an open feature request for that, starring it may help to push it forward. https://issuetracker.google.com/issues/35826944 – meh Mar 26 '17 at 10:33

2 Answers2

6

We are in 2017 and apparently this feature is still not implemented yet.

Even so, you can check the type(s) of the selected place on the activityResult and use it. In my case, I wanted the app only accept Hospitals and related services, so here's the code:

 @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//...
boolean isAnHospital = false;
selectedplace = PlacePicker.getPlace(this, data);
for (int i : selectedplace.getPlaceTypes()) {
    if (i == Place.TYPE_DOCTOR || i == Place.TYPE_HEALTH || i == Place.TYPE_HOSPITAL) {
                        isAnHospital = true;
                        break;
                    }
                }

if(isAnHospital){ 
    //Right type of place
}else{
    //Tell to the user to select an appropriate place 
      }           

Hope it helps in some way. Sorry for the bad english.

Thiago Leonel
  • 111
  • 1
  • 4
2

This is still not possible (14 September 2015).

Here is the open issue.

(info copied from related post, and reverified)

Community
  • 1
  • 1
Richard Le Mesurier
  • 29,432
  • 22
  • 140
  • 255