如何从 PlacePicker 获取 Lat Lng 坐标并将其放置在 Map Fragment 上?
How to get Lat Lng coordinates from PlacePicker and place it on Map Fragment?
我正在实现 MapsActivity
和 PlacePicker
。我已将 Placepicker
实现方法放在 getMapReady
函数中。
当我 运行 它时,首先会出现一个 placepicker 并询问 select 特定位置,然后它会转到 mylocation 而不是 placepicker selected 位置。
任何人对此有想法。
我试过 LatLngBounds
但没试过 successful.Thanks.
我希望你已经尝试过如下:
int PLACE_PICKER_REQUEST = 1;
PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
startActivityForResult(builder.build(this), PLACE_PICKER_REQUEST);
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == PLACE_PICKER_REQUEST) {
if (resultCode == RESULT_OK) {
Place place = PlacePicker.getPlace(data, this);
String toastMsg = String.format("Place: %s", place.getName());
Toast.makeText(this, toastMsg, Toast.LENGTH_LONG).show();
// Here, get the position of the place, mark it in map and moveCamera to that, couple lines of code.
}
}
}
我正在实现 MapsActivity
和 PlacePicker
。我已将 Placepicker
实现方法放在 getMapReady
函数中。
当我 运行 它时,首先会出现一个 placepicker 并询问 select 特定位置,然后它会转到 mylocation 而不是 placepicker selected 位置。
任何人对此有想法。
我试过 LatLngBounds
但没试过 successful.Thanks.
我希望你已经尝试过如下:
int PLACE_PICKER_REQUEST = 1;
PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
startActivityForResult(builder.build(this), PLACE_PICKER_REQUEST);
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == PLACE_PICKER_REQUEST) {
if (resultCode == RESULT_OK) {
Place place = PlacePicker.getPlace(data, this);
String toastMsg = String.format("Place: %s", place.getName());
Toast.makeText(this, toastMsg, Toast.LENGTH_LONG).show();
// Here, get the position of the place, mark it in map and moveCamera to that, couple lines of code.
}
}
}