Question

I have an Android app with a MapView, and zoom controls have been implemented. But I want to detect when the zoom level has changed, so I can do certain things when that happens. Is there any listener to do that? Any example?

Was it helpful?

Solution

With a little bit of research, I found this site:

http://pa.rezendi.com/2010/03/responding-to-zooms-and-pans-in.html

Specifically, this code:

int oldZoomLevel=-1;

public void dispatchDraw(Canvas canvas) {
 super.dispatchDraw(canvas);
  if (getZoomLevel() != oldZoomLevel) {
   //do your thing
   oldZoomLevel = getZoomLevel();
  }
}

Would seem to do more or less what you want.

Edit:

In other words, you can solve this by subclassing the mapview, and override the dispatchDraw.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top