我的代码是这样的。它工作正常。
如何设置纬度和经度,PlacePicker.IntentBuilder
以便我可以在地图上看到位置
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);
}
请帮帮我。