android - Disable my-location when user moves the map and re-enable when he press the my-location button -


i'm using setmylocationenabled(true) google maps android api v2 have auto location tracking , display indicator google maps app. need camera position follows my-location indicator visible, except when user pans map.

so, i'm using onmylocationchange method move camera new location, when user pans map or use search field app, onmylocationchange continues being called , camera comes my-location coordinates.

how can move camera automatically when my-location enabled, disable when map manually manipulated (pan, rotate or search) , enable when user press my-location button?

thanks.

edit:

there googlemap.setonmylocationbuttonclicklistener, can skip point 1 , use that.


you can't february version of maps api v2. best thing can to:

  1. have own "go location" button know when want start tracking
  2. your own location change listener
  3. a view on top of supportmapfragment ontouchlistener (returning false!) know when need stop tracking

this solution not perfect, stop tracking before user zooms on pans - stop when first touch map, think solution not make confusion users: touched map, can expect tracking stop , can press button start it.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -