Java ME引路蜂地图开发示例:放大、缩小

jerry 地图开发 2015年11月26日 收藏

RasterMap的 zoomIn,zoomOut 用来放大缩小地图。 

  1. //------------------------------------------------------------------------------
  2. //                         COPYRIGHT 2011 GUIDEBEE
  3. //                           ALL RIGHTS RESERVED.
  4. //                     GUIDEBEE CONFIDENTIAL PROPRIETARY
  5. ///////////////////////////////////// REVISIONS ////////////////////////////////
  6. // Date       Name                 Tracking #         Description
  7. // ---------  -------------------  ----------         --------------------------
  8. // 28JAN2011  James Shen                              Initial Creation
  9. ////////////////////////////////////////////////////////////////////////////////
  10. //--------------------------------- PACKAGE ------------------------------------
  11. package com.pstreets.gisengine.demo.midp; 
  12.  
  13. //--------------------------------- IMPORTS ------------------------------------
  14. import com.mapdigit.gis.geometry.GeoLatLng;
  15. import com.mapdigit.gis.raster.MapType;
  16. import com.pstreets.gisengine.demo.MapDemoMIDP;
  17. import javax.microedition.lcdui.Command;
  18. import javax.microedition.lcdui.CommandListener;
  19. import javax.microedition.lcdui.Display;
  20. import javax.microedition.lcdui.Displayable; 
  21.  
  22. //[------------------------------ MAIN CLASS ----------------------------------]
  23. //--------------------------------- REVISIONS ----------------------------------
  24. // Date       Name                 Tracking #         Description
  25. // --------   -------------------  -------------      --------------------------
  26. // 28JAN2011  James Shen                              Initial Creation
  27. ////////////////////////////////////////////////////////////////////////////////
  28. /**
  29.  *  map zoom demo for Guidebee Map API on MIDP platform.
  30.  * <hr><b>&copy; Copyright 2011 Guidebee, Inc. All Rights Reserved.</b>
  31.  * @version     1.00, 28/01/11
  32.  * @author      Guidebee Pty Ltd.
  33.  */
  34. public class MapZoomMIDP extends MapDemoMIDP implements CommandListener{ 
  35.  
  36.     private Command mapZoomInCommand=new Command("Zoom In",Command.OK,1);
  37.     private Command mapZoomOutCommand=new Command("Zoom Out",Command.CANCEL,1); 
  38.  
  39.     public void startApp() {
  40.         init();
  41.         canvas.addCommand(mapZoomInCommand);
  42.         canvas.addCommand(mapZoomOutCommand);
  43.         canvas.setCommandListener(this);
  44.         GeoLatLng center = new GeoLatLng(32.0616667, 118.7777778);
  45.         map.setCenter(center, 13, MapType.MICROSOFTCHINA);
  46.         Display.getDisplay(this).setCurrent(canvas);
  47.     } 
  48.  
  49.      public void commandAction(Command c, Displayable d) {
  50.         if(c==mapZoomInCommand){
  51.             map.zoomIn(); 
  52.  
  53.         }else if(c==mapZoomOutCommand){
  54.             map.zoomOut();
  55.         }
  56.     }
  57. } 
  58.