sil*_*ave 19 android google-maps google-maps-api-3 android-location google-places-api
我正在制作一些需要用户选择地点的Android应用程序.我打算到用户谷歌的地方API.Link:https://developers.google.com/places/android/
通过Place Picker,这个API提供了很好的方法.https://developers.google.com/places/android/placepicker
现在假设我只想显示食物类型的用户地点(餐馆,酒店等).使用Places Browser API可以通过在请求中添加"type = restraunts"属性来完成.
有没有办法只使用Google Places Picker for android显示某些类型的地方?
小智 6
我们在2017年,显然这个功能还没有实现.
即便如此,您可以在activityResult上检查所选位置的类型并使用它.在我的情况下,我希望该应用程序只接受医院和相关服务,所以这里是代码:
@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
}
Run Code Online (Sandbox Code Playgroud)
希望它在某种程度上有所帮助.抱歉英语不好.
| 归档时间: |
|
| 查看次数: |
3742 次 |
| 最近记录: |