dd

Blackberry引路蜂地图开发示例:设置地图类型

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

创建RasterMap实例之后,可以对其进行放大,缩小,平移,设置地图类型等操作。
在第一个地图应用中,在调用RasterMap.setCenter 时可以指定地图类型,另外也可以使用RasterMap.setMapType来更改地图类型,地图开发包中定义了Google 地图,Google 中国地图,Bing 地图,Bing 卫星图等20多种地图类型,也就可设置自已定义地图类型。
在项目RIMGISEngineTutorial创建MapTypeRIM,并添加maptype_menu 菜单。
下面的例子顺序显示Google 中国地图,MapAbc地图,Bing 中国地图。

//--------------------------------- PACKAGE ------------------------------
package com.pstreets.gisengine.demo.rim;

//--------------------------------- IMPORTS ------------------------------
import com.mapdigit.gis.geometry.GeoLatLng;
import com.mapdigit.gis.raster.MapType;
import com.pstreets.gisengine.demo.MapDemoRIM;
import net.rim.device.api.ui.component.Menu;
import net.rim.device.api.ui.MenuItem;

//[------------------------------ MAIN CLASS ----------------------------]
/**
 *  map type demo for Guidebee Map API on RIM platform.
 * <hr><b>&copy; Copyright 2010 Guidebee, Inc. All Rights Reserved.</b>
 * @version     1.00, 16/09/10
 * @author      Guidebee Pty Ltd.
 */
public class MapTypeRIM extends MapDemoRIM  {

    /**
     * Entry point for application
     * @param args Command line arguments (not used)
     */
    public static void main(String[] args)
    {
        // Create a new instance of the application and make the
       // currently running thread the application's event 
      //dispatch thread.
        MapTypeRIM theApp = new MapTypeRIM();      
        theApp.enterEventDispatcher();
    }
   
    private int mapType = 0;
    private static final int[] mapTypes = {MapType.GOOGLECHINA,
        MapType.MAPABCCHINA, MapType.MICROSOFTCHINA};
    private MenuItem mapTypeMenuItem = new MenuItem("MapType",0,1){
        public void run(){
            map.setMapType(mapTypes[mapType]);
            mapType++;
            mapType %= mapTypes.length;
        }
        };

    public MapTypeRIM() {

        init();
        pushScreen(canvas);
        GeoLatLng center = new GeoLatLng(32.0616667, 118.7777778);
        map.setCenter(center, 13, MapType.GOOGLECHINA);

    }

     protected void createMenu(Menu menu, int instance){
         menu.add(mapTypeMenuItem);

   }
}

dd