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

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

问题描述

我在我的应用程序中使用PlacePicker。突然间,它的表现很糟糕。当它发射指向(0.0,0.0)经度。
我不确定Google服务是否改变了某些内容。早些时候,它工作正常,因为从3天没有工作。



我在这里做错了什么



这是我如何启动活动。

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


$ / code $ / pre

这是我创建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);
返回新的LatLngBounds(西南,东北);
}

我尝试创建如下的LatLngBounds,结果仍然相同。

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

$ / code>

有人可以帮助我

不幸的是,您必须等待Google在未来的Google Play服务版本中解决问题。



您的代码没有任何问题,Google Play Services的最新更新引起了Place Picker UI小部件的一些严重问题。我首先注意到 setLatLngBounds()方法在Google Play Services 9.0.82中不再适用。在9.0.83中,搜索图标消失。



请参阅我的帖子,了解此问题: Android的PlacePicker不再有更新到谷歌播放服务9.0.83后的搜索图标



查看来自Google Maps API错误和功能网站的这些错误报告:
Bug:搜索图标在最新的播放服务更新中不可见(版本:9.0 .83) -----
Bug:放置选取器不显示搜索图标。 b $ b PlacePicker search图标在更新到Google Play服务9.0.83后消失了



您可以通过而不是来解决该问题,方法是调用setLatLngBounds () 方法。 PlacePicker将默认为您当前的位置。我在我的应用程序中失去了一些功能,但它比让最终用户试图从大西洋掐回来的方式要好。对我而言,失踪的搜索图标仍然是我的主要问题。


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.

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

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.

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.

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.

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

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

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天全站免登陆