我不知道如何获取结果,只知道附近的公共汽车站。我试过 go through place picker documentation for help。但它显示了所有 附近的地方,如果我只需要公共汽车站做什么。它会返回附近的所有地方如何获得我想要的东西
import android.Manifest;
import android.content.Intent;
import android.content.IntentSender;
import android.content.pm.PackageManager;
import android.location.Location;
import com.google.android.gms.common.GooglePlayServicesNotAvailableException;
import com.google.android.gms.common.GooglePlayServicesRepairableException;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.widget.Toast;
import com.google.android.gms.location.places.Place;
import com.google.android.gms.location.places.ui.PlacePicker;
import com.google.android.gms.maps.model.LatLngBounds;
import transportation.lumiumdesign.com.transportation.R;
/**
*
* It contains a place picker to detect current location and nearby bus stops to it.
*/
public class CurrentLocMap extends FragmentActivity {
int PLACE_PICKER_REQUEST = 1;//Predefined req_code
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.current_loc_map);
PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
/** Intent Builder will set current location of deviceif not provided
**/
try {
startActivityForResult(builder.build(this), PLACE_PICKER_REQUEST);
} catch (GooglePlayServicesRepairableException e) {
e.printStackTrace();
} catch (GooglePlayServicesNotAvailableException e) {
e.printStackTrace();
}
}
//onActivityResult will launch place picker
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == PLACE_PICKER_REQUEST) {
if (resultCode == RESULT_OK) {
Place place = PlacePicker.getPlace(this, data);
String toastMsg = String.format("Place: %s", place.getName());
Toast.makeText(this, toastMsg, Toast.LENGTH_LONG).show();
}
}
}
}
答案 0 :(得分:0)
不幸的是,即使将地点选择器类扩展为nowavewater已经测试的内容,也无法进行过滤。
您还可以对sidecarcat分享的更新执行以下两个未解决的问题:
https://code.google.com/p/gmaps-api-issues/issues/detail?id=8484
https://code.google.com/p/gmaps-api-issues/issues/detail?id=8565
但您可以尝试使用place autocomplete
Google Places API for Android中的自动填充服务会返回预测,以响应用户搜索查询。当用户键入时,自动填充服务会返回诸如商家,地址和兴趣点等位置的建议。
您可以设置自动填充小部件,将结果偏向特定地理区域,和/或将结果过滤为一种或多种地点类型。
要将自动填充结果过滤为特定地点类型,请致电
AutocompleteFilter.Builder
以创建新的AutocompleteFilter
,调用setTypeFilter()
设置要使用的过滤器。然后,将过滤器传递给片段或意图。
代码示例:
AutocompleteFilter typeFilter = new AutocompleteFilter.Builder()
.setTypeFilter(AutocompleteFilter.TYPE_FILTER_ADDRESS)
.build();
Intent intent =
new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_FULLSCREEN)
.setFilter(typeFilter)
.build(this);