开发者

Detecting zoom changes at MapView

开发者 https://www.devze.com 2023-04-11 08:29 出处:网络
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 ther开发者_开发问答

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 ther开发者_开发问答e any listener to do that? Any example?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号