【发布时间】:2016-09-14 18:51:02
【问题描述】:
我在我的应用程序中使用 PlacePicker。突然间它的行为很糟糕。当它启动时,它指向 (0.0, 0.0) lat lng。 我不确定谷歌服务是否改变了一些东西。早些时候它工作得很好,因为从 3 天开始它就不能工作了。
我在这里做错了吗
这就是我启动 Activity 的方式。
private void launchPlacePicker(double latitude, double longitude) {
try {
showProgress(true);
PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
Log.d(TAG, " launchPlacePicker " + latitude + " " + longitude);
builder.setLatLngBounds(MapUtils.getLatLngBounds(new LatLng((double) latitude, (double) longitude)));
startActivityForResult(builder.build(this), PLACE_PICKER_REQUEST);
} catch (GooglePlayServicesRepairableException e) {
showProgress(false);
Log.e(TAG, "GooglePlayServicesRepairableException", e);
} catch (GooglePlayServicesNotAvailableException e) {
showProgress(false);
Log.e(TAG, "GooglePlayServicesNotAvailableException", e);
}
}
这就是我创建 LatLngBounds 的方式
public static LatLngBounds getLatLngBounds(LatLng center) {
double radius = 100;
LatLng southwest = SphericalUtil.computeOffset(center, radius * Math.sqrt(2.0), 225);
LatLng northeast = SphericalUtil.computeOffset(center, radius * Math.sqrt(2.0), 45);
return new LatLngBounds(southwest, northeast);
}
我尝试创建如下所示的 LatLngBounds,结果仍然相同。
public static LatLngBounds getLatLngBounds(LatLng center) {
LatLngBounds.Builder builder = LatLngBounds.builder();
builder.include(center);
return builder.build();
}
谁能帮帮我
【问题讨论】:
标签: android google-maps android-studio