Android Google 服务地点选择器 setLatLngBounds() 不起作用 [英] Android Google Service Place picker setLatLngBounds() not working

查看:32
本文介绍了Android Google 服务地点选择器 setLatLngBounds() 不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用中使用 PlacePicker.突然间它的行为很糟糕.当它启动时,它指向 (0.0, 0.0) lat lng.我不确定 Google 服务是否有所改变.早些时候它运行良好,因为从 3 天起它就不起作用了.

I am using PlacePicker in my App. All of sudden its behaving badly. When its launched its pointing to (0.0, 0.0) lat lng. I am not sure if Google service changed something. earlier it was working all fine since from 3 days its not working.

我在这里做错了什么

这就是我启动 Activity 的方式.

This is How I am launching 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 的方式

This is how I am creating 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,结果仍然相同.

and I tried to create LatLngBounds like below, still same result.

public static LatLngBounds getLatLngBounds(LatLng center) {
    LatLngBounds.Builder builder = LatLngBounds.builder();
    builder.include(center);
    return builder.build();
}

谁能帮帮我

推荐答案

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

Unfortunately you are going to have to wait for Google to fix the issue in a future release of Google Play Services.

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

There is not anything wrong with your code, the latest update of Google Play Services causes some serious issues with the Place Picker UI widget. I first noticed the setLatLngBounds() method no longer works in Google Play Services 9.0.82. In 9.0.83, the search icon disappeared.

请参阅我关于此问题的帖子:Android PlacePicker 更新到 Google Play Services 9.0.83 后不再有搜索图标

See my post regarding this issue: Android PlacePicker no longer has Search icon after updating to Google Play Services 9.0.83

从 Google Maps API 错误和功能网站查看这些错误报告:Bug:在最新的播放服务更新(版本:9.0.83)中看不到搜索图标 -----错误:地点选择器未显示搜索图标. -----更新到 Google Play 服务 9.0.83 后,PlacePicker 搜索图标消失了

See these bug reports from the Google Maps API bug and feature website: 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 将默认为您当前的位置.我在我的应用程序中丢失了一些功能,但这比让最终用户尝试从大西洋回来的路上要好得多.对我来说,缺少搜索图标仍然是我的主要问题.

You can somewhat work around the issue by not invoking the setLatLngBounds() method. PlacePicker will default to your current location. I lost some functionality in my app, but it was better than having the end user try to pinch and pan their way back from the Atlantic Ocean. For me, the missing search icon is still my major issue.

这篇关于Android Google 服务地点选择器 setLatLngBounds() 不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆