简体   繁体   English

Google Map API V2回调,用于在地图上显示显示用户位置的蓝点

[英]Google map api v2 callback for when the blue dot showing the user's location appears on the map

I am currently showing the user's current location on the map with 我目前正在用来在地图上显示用户的当前位置

setMyLocationEnabled(true);

Is there a callback or another way I can tell when the blue dot showing the current location appears on the map. 是否有回调或其他方法可以告知显示当前位置的蓝点何时出现在地图上。 I can setup a LocationListener and assume that when onLocationChanged is called that the blue dot is showing on the map but I don't need location updates in my app so implementing a LocationListener seems like overkill. 我可以设置一个LocationListener并假设在onLocationChanged时,地图上会显示蓝点,但是我不需要在应用程序中更新位置,因此实现LocationListener似乎有点过头。 I couldn't find any interfaces to implement in the documentation for a callback such as this. 我在此类回调的文档中找不到要实现的接口。 Does anyone know of any other approaches I can use? 有人知道我可以使用其他任何方法吗?

You can add a listener to location change directly on the GoogleMap object. 您可以直接在GoogleMap对象上为位置更改添加侦听器。 Then remove it after the first callback if you're not interested in further updates. 如果您对进一步的更新不感兴趣,请在第一个回调之后将其删除。

Check setOnMyLocationChangeListener() . 检查setOnMyLocationChangeListener()

It's deprecated, but it works (or at least it did work - I haven't used it recently). 它是过时了,但它的工作原理(或至少它工作-我最近没有使用它)。

Seems like most of the location methods are depreciated for android. 似乎大多数定位方法已针对android折旧。 The one under development is the Location client. 正在开发的是位置客户端。 And from the documentation 并且从文档

This interface is deprecated. 不推荐使用此接口。 use LocationClient instead. 请改用LocationClient。 LocationClient provides improved location finding and power usage and is used by the "My Location" blue dot. LocationClient提供了改进的位置查找功能和电源使用方式,并且由“我的位置”蓝点使用。 See the MyLocationDemoActivity in the sample applications folder for example example code, or the Location Developer Guide. 有关示例代码示例,请参见示例应用程序文件夹中的MyLocationDemoActivity或《位置开发人员指南》。

And as for the interface LocationClient.requestLocationUpdates() seems to be the way to go. 至于接口LocationClient.requestLocationUpdates()似乎是要走的路。

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

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