0
我的代碼是這樣的。它工作正常。
我怎麼能在PlacePicker.IntentBuilder
設置緯度和經度,這樣我可以看到在地圖中的位置我可以在PlacePicker.IntentBuilder中設置LatLngObject以在地圖中看到該地點嗎?
try {
PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
Intent intent = builder.build(MainActivity.this);
startActivityForResult(intent, PLACE_PICKER_REQUEST_CODE);
} catch (GooglePlayServicesRepairableException
| GooglePlayServicesNotAvailableException e) {
e.printStackTrace();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == PLACE_PICKER_REQUEST_CODE) {
final Place place = PlacePicker.getPlace(this, data);
final CharSequence name = place.getName();
final CharSequence address = place.getAddress();
Khet_Location = address.toString();
Place_Name = name + "," + address;
String attributions = (String) place.getAttributions();
if (attributions == null) {
attributions = "";
}
current_location_id.setVisibility(View.VISIBLE);
current_location_id.setText(Place_Name);
Double latitude = place.getLatLng().latitude;
Double longitude = place.getLatLng().longitude;
Address_lat = String.valueOf(latitude);
Address_long = String.valueOf(longitude);
}else
super.onActivityResult(requestCode, resultCode, data);
}
請幫助我。