谷歌地图Android的API第2版 - 与pcated我的位置去$ P $的API。为什么? [英] Google Maps Android API v2 - APIs related to my location deprecated. Why?

查看:334
本文介绍了谷歌地图Android的API第2版 - 与pcated我的位置去$ P $的API。为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于谷歌I / O 2013,我们可以在几个地方谷歌地图的文档阅读Android的API V2

Since the Google I/O 2013 we can read in several places of the documentation of Google Maps Android API v2 that

此方法/接口德precated。

This method / interface is deprecated.

使用com.google.android.gms.location.LocationClient代替。 LocationClient提供了改进的位置,发现和电源使用情况,所使用的我的位置蓝点。见MyLocationDemoActivity中的示例应用程序文件夹,例如例如code,或位置开发指南

use com.google.android.gms.location.LocationClient instead. LocationClient provides improved location finding and power usage and is used by the "My Location" blue dot. See the MyLocationDemoActivity in the sample applications folder for example example code, or the Location Developer Guide.

虽然它是伟大的新的API出现,我想不出什么好的理由把 @德precated 这些方法。

While it is great the new API appeared, I can't think of any good reason to put @Deprecated on these methods.

他们的确是访问的位置非常方便地指向了蓝点。

They are indeed a very convenient way of accessing location pointed to by the blue dot.

一个单行

Location location = map.getMyLocation();

要找回我的位置VS的设置code,我们需要使用新的位置API来实现同样的结果对讲让他们去precated编写量。

to retrieve my location vs the amount of setup code we need to write using the new Location API to achieve the same result speaks against having them deprecated.

从MyLocationDemoActivity(下<$c$c>ANDROID_SDK/extras/google/google_play_services/samples/maps/src/com/example/mapdemo/MyLocationDemoActivity.java):

From the MyLocationDemoActivity (under ANDROID_SDK/extras/google/google_play_services/samples/maps/src/com/example/mapdemo/MyLocationDemoActivity.java):

// These settings are the same as the settings for the map. They will in fact give you updates at
// the maximal rates currently possible.
private static final LocationRequest REQUEST = LocationRequest.create()
        .setInterval(5000)         // 5 seconds
        .setFastestInterval(16)    // 16ms = 60fps
        .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

该评论表明,这些硬codeD值是相同的,在地图上,但是这可能在将来不期望的方式改变。

The comment suggests that these hardcoded values are the same as in the map, but this may change in an undesirable way in future.

所以在所有的优点和缺点都在这里,这可能是背后desision的理由去precate这些API?

So after all the pros and cons are here, what could be the reason behind desision to deprecate these APIs?.

推荐答案

还有一点。如果GoogleMap的使用LocationClient,但我们并没有获得它的结果,我们不得不使用监听器的另一个LocationClient和一堆,它是两个LocationClients完成同样的任务。资源的纯浪费。

One more point. If GoogleMap uses LocationClient, but we don't have access to its results and we have to use another LocationClient and bunch of listeners, it is two LocationClients for the same task. Pure waste of resources.

这篇关于谷歌地图Android的API第2版 - 与pcated我的位置去$ P $的API。为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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