How to detect Google MapView movement in Android?

I would like to dynamically update maps / load new map overlays every time my user moves it a certain distance. How can I do it? Is there a listener for every user who moves the map? Most likely, I would only measure the distance between the center points.

Thanks!

+7
source share
3 answers

Try this to detect map movements: http://pa.rezendi.com/2010/03/responding-to-zooms-and-pans-in.html

At the beginning and after moving the map, you must save the current center of the map. As the article shows, track ACTION_UP to determine when the user has finished moving the map. Then compare the new center of the map with the old center of the map. To get map centers, use MapView getMapCenter ():

http://code.google.com/android/add-ons/google-apis/reference/com/google/android/maps/MapView.html#getMapCenter ()

EDIT: I did some extra work on this and have a complete code application for your enjoyment. This blog post explains this timer solution and contains a link to a Github source: http://bricolsoftconsulting.com/extending-mapview-to-add-a-change-event/

+8
source

The map interface, unfortunately, does not include listeners for monitoring map actions (zooming / panning). You will need to set up some kind of timer that checks the left center / zoom to find out if things have changed and updated accordingly.

0
source

You can do this by overriding the onTouch(...) method in Activity (so that every time a user clicks on a map, you can recalculate the borders of the map). You will need to know the zoom level and boundaries of the map, etc., in order to load these overlays based on the distances on the map.

0
source

All Articles