Monday, January 17, 2011

Map Operation --Zoom In, Zoom Out

RasterMap’s ZoomIn, ZoomOut are used to zoom in and zoom out the map.
public class MapZoomMIDP extends MapDemoMIDP implements CommandListener{

    private Command mapZoomInCommand=new Command("Zoom In",Command.OK,1);
    private Command mapZoomOutCommand=new Command("Zoom Out",Command.CANCEL,1);

    public void startApp() {
        init();
        canvas.addCommand(mapZoomInCommand);
        canvas.addCommand(mapZoomOutCommand);
        canvas.setCommandListener(this);
        GeoLatLng center = new GeoLatLng(32.0616667, 118.7777778);
        map.setCenter(center, 13, MapType.MICROSOFTCHINA);
        Display.getDisplay(this).setCurrent(canvas);
    }

     public void commandAction(Command c, Displayable d) {
        if(c==mapZoomInCommand){
            map.zoomIn();

        }else if(c==mapZoomOutCommand){
            map.zoomOut();
        }
    }
}





No comments:

Post a Comment