【发布时间】:2015-04-11 23:33:10
【问题描述】:
我正在尝试使用 Google Places API,并且我想将我的搜索过滤到仅健身房类型。
我正在使用https://developers.google.com/places/提供的代码
public void onPickButtonClick(View v) {
// Construct an intent for the place picker
try {
PlacePicker.IntentBuilder intentBuilder =
new PlacePicker.IntentBuilder();
Intent intent = intentBuilder.build(this);
// Start the intent by requesting a result,
// identified by a request code.
startActivityForResult(intent, REQUEST_PLACE_PICKER);
} catch (GooglePlayServicesRepairableException e) {
// ...
} catch (GooglePlayServicesNotAvailableException e) {
// ...
}
}
@Override
protected void onActivityResult(int requestCode,
int resultCode, Intent data) {
if (requestCode == REQUEST_PLACE_PICKER
&& resultCode == Activity.RESULT_OK) {
// The user has selected a place. Extract the name and address.
final Place place = PlacePicker.getPlace(data, this);
final CharSequence name = place.getName();
final CharSequence address = place.getAddress();
String attributions = PlacePicker.getAttributions(data);
if (attributions == null) {
attributions = "";
}
mViewName.setText(name);
mViewAddress.setText(address);
mViewAttributions.setText(Html.fromHtml(attributions));
} else {
super.onActivityResult(requestCode, resultCode, data);
}
}
我试图做的是创建一个像下面这样的过滤器,并以某种方式将它 (placeFilter) 添加到意图中。
PlacePicker.IntentBuilder intentBuilder = new PlacePicker.IntentBuilder();
PlaceFilter placeFilter;
ArrayList<String> restictToGyms = new ArrayList<>();
restictToGyms.add("44");
placeFilter = new PlaceFilter(false, restictToGyms);
intent.SOMEHOWADD(placeFilter);
Intent intent = intentBuilder.build(this);
但我不确定如何将此过滤器添加到意图中。事实上,我不确定这是否是正确的做法。任何指针将不胜感激。谢谢!
【问题讨论】:
-
目前有一个开放的功能请求:issuetracker.google.com/issues/35826944 随意“星标”它可能会有所帮助。
标签: android google-maps-android-api-2 google-places-api