Tôi đang sử dụng PlacePicker
API trong ứng dụng của mình và muốn thay đổi loại bản đồ từ đơn giản thành vệ tinh.Cách thay đổi loại bản đồ từ đơn giản thành vệ tinh của PlacePicker từ API Google Địa điểm?
PlacePicker là một API do Google cung cấp.
Đây là cách tôi đang sử dụng nó:
// 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();
// ...
}
và sau đó trong 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);
}
}
Nó chỉ cho thấy các loại bản đồ đơn giản. Tôi muốn hiển thị bản đồ loại vệ tinh.
Vui lòng cho tôi biết cách thực hiện?
Tôi nghĩ rằng không có tùy chọn nào được cung cấp. Bởi vì nếu bạn thấy tài liệu cho điều này, nó không được đề cập ở bất cứ đâu về loại bản đồ cho địa điểm api. Nó là thú vị để biết liệu nó có thể hay không. –