I would like to have onZoomListener on my MapView. The code below is what I have done. It registers if zoom buttons are tapped. Since all new phones now supports pinch to zoom, this is useless. Does anybody have idea how to do real onZoomListener? Thanks.
OnZoomListener listener = new OnZoomListener() {
@Override
public void onVisibilityChanged(boolean arg0) {
// TODO Auto-generated method stub
}
@Override
public void onZoom(boolean arg0) {
Log.d(TAG, "ZOOM CHANGED");
// TODO Auto-generated method stub
}
};
ZoomButtonsController zoomButton = mapView.getZoomButtonsController();
zoomButton.setOnZoomListener(listener);
I put all the code from above together and came up with this class:
And the corresponding listener interface:
MapView provides build-in zoom controls that support pinch. If it doesn't work out of the box you could try setting
mapView.setBuiltInZoomControls(true);
This way you should not need the OnZoomListener.i implemented it the following way, and it works for single/multitouch :
It worked for me!
Try via this method
Edit: I believe what you've found is probably the only mechanism to allow this detection. (Editing my post to remove misinformation) Extending the MapView and overriding the onDraw() method would work. One consideration to make will be how often to fire the code listening to zoom. For instance, while zooming the onDraw may be called dozens of times each with a different zoom level. This may cause poor performance if your listener is firing every time. You could throttle this by determining that a zoom change has taken place and then waiting for the zoom level to be the same on two subsequent redraws before firing the event. This all depends on how you want your code to be called.
Maybe a bit late, but have you tried with an OnOverlayGestureListener?
http://code.google.com/p/mapview-overlay-manager/wiki/OnOverlayGestureListener