user757420
user757420

Reputation: 19

How would I update marker position in google map when user current Position is changed?

I want whenever my current location is changed than marker position is also update and it appear in it's next new location in map .?

Upvotes: 0

Views: 2604

Answers (3)

Peter Knego
Peter Knego

Reputation: 80350

You simply use MyLocationOverlay: http://code.google.com/android/add-ons/google-apis/reference/com/google/android/maps/MyLocationOverlay.html

No need to listen to GPS as MyLocationOverlay manages this automatically.

Upvotes: 2

Aleadam
Aleadam

Reputation: 40401

You need to implement LocationListener and update your MapView in the onLocationChanged callback

abstract void     onLocationChanged(Location location)

Called when the location has changed.

There's a topic in the dev guide about this: http://developer.android.com/guide/topics/location/obtaining-user-location.html

Upvotes: 2

keyser
keyser

Reputation: 19189

For the LocationManager class:

To get one update you can use getLastKnownLocation(String)

or requestLocationUpdates(long minTime, float minDistance, Criteria criteria, PendingIntent intent) if you want periodical updates.

If you aren't using LocationManager, please specify what you're trying to do :)

Hope it works, and good luck!

Upvotes: 1

Related Questions