简体   繁体   English

Android Google服务广告选择器setLatLngBounds()无效

[英]Android Google Service Place picker setLatLngBounds() not working

I am using PlacePicker in my App. 我在我的应用程序中使用PlacePicker。 All of sudden its behaving badly. 突然间,它表现得很糟糕。 When its launched its pointing to (0.0, 0.0) lat lng. 当它发射时指向(0.0,0.0)lat lng。 I am not sure if Google service changed something. 我不确定Google服务是否有所改变。 earlier it was working all fine since from 3 days its not working. 早些时候它工作得很好,因为从3天开始它不起作用。

Am I doing anything wrong here 我在这做错了吗?

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);
    }
}

This is how I am creating LatLngBounds 这就是我创建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);
}

and I tried to create LatLngBounds like below, still same result. 我尝试创建如下的LatLngBounds,结果仍然相同。

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

could some one help me 可能有人帮助我

Unfortunately you are going to have to wait for Google to fix the issue in a future release of Google Play Services. 很遗憾,您将不得不等待Google在未来的Google Play服务版本中解决此问题。

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. 您的代码没有任何问题,Google Play服务的最新更新会导致Place Picker UI小部件出现严重问题。 I first noticed the setLatLngBounds() method no longer works in Google Play Services 9.0.82. 我首先注意到setLatLngBounds()方法在Google Play Services 9.0.82中不再有效。 In 9.0.83, the search icon disappeared. 在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 Play Services 9.0.83后,Android 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. 请参阅Google Maps API错误和功能网站上的这些错误报告: 错误:搜索图标在最新的播放服务更新(版本:9.0.83)中不可见 ----- 错误:地方选择器未显示搜索图标。 ----- PlacePicker search icon is gone after updating to Google Play Services 9.0.83 ----- 更新到Google Play Services 9.0.83后,PlacePicker搜索图标消失了

You can somewhat work around the issue by not invoking the setLatLngBounds() method. 您可以通过调用setLatLngBounds()方法来解决此问题。 PlacePicker will default to your current location. PlacePicker将默认为您当前的位置。 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. 对我来说,丢失的搜索图标仍然是我的主要问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM