Muhammad Umar
Muhammad Umar

Reputation: 11782

Gps LocationListenser for GoogleMaps V2 in android

I am trying to understand the relationship between googlemaps LatLng and Location class. Are they convertable ? I am using

GoogleMaps v2

in my application so How can I use my GPS To locate my position on maps

Upvotes: 0

Views: 168

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006644

You can call setMyLocationEnabled(true) on your GoogleMap and then just call getMyLocation() periodically, if you wish. Otherwise, in addition to calling setMyLocationEnabled(true), you can:

Step #1: Set up a LocationListener using LocationManager.

Step #2: Call setLocationSource() on your GoogleMap, supplying a LocationSource implementation

Step #3: In the LocationSource implementation, hold onto the listener object supplied to you in activate()

Step #4: When location fixes come into your LocationListener, pass them to the listener you were provided in activate()

Here is a sample project demonstrating this.

Upvotes: 1

Related Questions