gpt4 book ai didi

Android 谷歌服务地点选择器设置 LatLngBounds() 不工作

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:01:11 25 4
gpt4 key购买 nike

我在我的应用程序中使用 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();
}

谁能帮帮我

最佳答案

很遗憾,您将不得不等待 Google 在未来的 Google Play 服务版本中解决该问题。

您的代码没有任何问题,Google Play 服务的最新更新导致地点选择器 UI 小部件出现一些严重问题。我首先注意到 setLatLngBounds() 方法在 Google Play Services 9.0.82 中不再有效。在 9.0.83 中,搜索图标消失了。

请参阅我关于此问题的帖子:Android PlacePicker no longer has Search icon after updating to Google Play Services 9.0.83

请参阅来自 Google Maps API 错误和功能网站的错误报告: Bug: Search Icon not visible in the latest play service update (Version:9.0.83) ------ Bug: Place Picker not showing search icon. ------ PlacePicker search icon is gone after updating to Google Play Services 9.0.83

您可以通过调用 setLatLngBounds() 方法来稍微解决这个问题。 PlacePicker 将默认为您当前的位置。我在我的应用程序中丢失了一些功能,但这总比让最终用户尝试从大西洋往回移动要好。对我来说,缺少搜索图标仍然是我的主要问题。

关于Android 谷歌服务地点选择器设置 LatLngBounds() 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37296991/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com