我的代码是这样的。它工作正常。
如何在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);
}
请帮帮我。
答案 0 :(得分:1)
你的意思是集中所有地点选择器,我不太了解你的问题......
但请检查this...
setLatLngBounds(LatLngBounds latLngBounds)
例如
for i to n{
array coords
add in LatLngBounds
}
placepicker.setLatLngBounds(latLngBounds)