简体   繁体   中英

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. 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. Then remove it after the first callback if you're not interested in further updates.

Check 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. The one under development is the Location client. And from the documentation

This interface is deprecated. use 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.

And as for the interface LocationClient.requestLocationUpdates() seems to be the way to go.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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