开发者

OnZoom method not working in MapActivity

开发者 https://www.devze.com 2023-02-14 06:03 出处:网络
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开

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

        }
    });
0

精彩评论

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

关注公众号