Im trying to limit the zoom levels of my map, by implementing the OnZoomListener
in my MapActivity
class. This listener has the OnZoom()
method which is called automatically when the user uses the zo开发者_如何学JAVAom controls. Now in this OnZoom()
method i have put in:
public void onZoom(boolean zoomIn) {
int mylevel=map.getZoomLevel();
if(mylevel>15){
mc.zoomOut();
}
Here mc is my mapcontroller.
but this isnt working...any solutions?
thx.
EDIT: well...this didnt get any solutions :|
I can't see any onZoom method to be overriden in MapActivity -- try @Override annotation and you'll see what I mean ... well at least for v 8_r1
I was also having the same problem. Instead of implementing the interface, add the following code in your onCreate()
final MapView mapView = (MapView) findViewById(R.id.mapView);
ZoomButtonsController controller = mapView.getZoomButtonsController();
controller.setOnZoomListener(new ZoomButtonsController.OnZoomListener() {
@Override
public void onZoom(boolean zoomIn) {
Log.i(TAG,"Inside onZoom. value is "+zoomIn);
if(zoomIn)
mapView.getController().zoomIn();
else
mapView.getController().zoomOut();
}
@Override
public void onVisibilityChanged(boolean visible) {
// TODO Auto-generated method stub
}
});
精彩评论