我在我的应用程序中使用 PlacePicker
API,并希望将其 map 类型从简单 map 更改为卫星 map 。
PlacePicker是 Google 提供的 API。
我是这样使用它的:
// 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, PLACE_PICKER_REQUEST);
} catch (GooglePlayServicesRepairableException e) {
Snackbar snackbar = Snackbar
.make(coordinatorLayout, e.getMessage(), Snackbar.LENGTH_SHORT);
snackbar.show();
// ...
} catch (GooglePlayServicesNotAvailableException e) {
Snackbar snackbar = Snackbar
.make(coordinatorLayout, e.getMessage(), Snackbar.LENGTH_SHORT);
snackbar.show();
// ...
}
然后在 onActivityResult()
中:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == PLACE_PICKER_REQUEST
&& 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();
LatLng latLng = place.getLatLng();
final double lat = latLng.latitude;
final double lng = latLng.longitude;
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);
}
}
它只显示简单的 map 类型。我想显示卫星类型的 map 。
请告诉我怎么做?
最佳答案
目前无法在 Place Picker 中更改 map 类型。您可以在 Place API 的 public issue tracker 上添加功能请求.
关于java - 如何从 Google Places API 将 PlacePicker 的 map 类型从简单更改为卫星?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40777156/