Sha*_*adi 10 android google-maps android-studio
我在我的应用程序中使用PlacePicker.突然间,它表现得很糟糕.当它发射时指向(0.0,0.0)lat lng.我不确定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);
}
}
Run Code Online (Sandbox Code Playgroud)
这就是我创建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);
}
Run Code Online (Sandbox Code Playgroud)
我尝试创建如下的LatLngBounds,结果仍然相同.
public static LatLngBounds getLatLngBounds(LatLng center) {
LatLngBounds.Builder builder = LatLngBounds.builder();
builder.include(center);
return builder.build();
}
Run Code Online (Sandbox Code Playgroud)
可能有人帮助我
Dan*_*oss 14
很遗憾,您将不得不等待Google在未来的Google Play服务版本中解决此问题.
您的代码没有任何问题,Google Play服务的最新更新会导致Place Picker UI小部件出现严重问题.我首先注意到setLatLngBounds()方法在Google Play Services 9.0.82中不再有效.在9.0.83中,搜索图标消失了.
查看有关此问题的帖子:更新到Google Play Services 9.0.83后,Android PlacePicker不再具有搜索图标
请参阅Google Maps API错误和功能网站上的这些错误报告: 错误:搜索图标在最新的播放服务更新(版本:9.0.83)中不可见 ----- 错误:地方选择器未显示搜索图标.----- 更新到Google Play Services 9.0.83后,PlacePicker搜索图标消失了
您可以通过不调用setLatLngBounds()方法来解决此问题.PlacePicker将默认为您当前的位置.我在我的应用程序中丢失了一些功能,但它比让最终用户试图从大西洋捏回来的方式更好.对我来说,丢失的搜索图标仍然是我的主要问题.
| 归档时间: |
|
| 查看次数: |
2720 次 |
| 最近记录: |