创建RasterMap实例之后,可以对其进行放大,缩小,平移,设置地图类型等操作。
在第一个地图应用中,在调用RasterMap.setCenter 时可以指定地图类型,另外也可以使用RasterMap.setMapType来更改地图类型,地图开发包中定义了Google 地图,Google 中国地图,Bing 地图,Bing 卫星图等20多种地图类型,也就可设置自已定义地图类型。
下面的例子顺序显示Google 中国地图,MapAbc地图,Bing 中国地图
package com.pstreets.gisengine.demo.midp;
//--------------------------------- IMPORTS ------------------------------------
import com.mapdigit.gis.geometry.GeoLatLng;
import com.mapdigit.gis.raster.MapType;
import com.pstreets.gisengine.demo.MapDemoMIDP;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
//[------------------------------ MAIN CLASS ----------------------------------]
/**
* map type demo for Guidebee Map API on MIDP platform.
* <hr><b>© Copyright 2011 Guidebee, Inc. All Rights Reserved.</b>
* @version 1.00, 28/01/11
* @author Guidebee Pty Ltd.
*/
public class MapTypeMIDP extends MapDemoMIDP implements CommandListener {
private int mapType = 0;
private static final int[] mapTypes = {MapType.GOOGLECHINA,
MapType.MAPABCCHINA, MapType.MICROSOFTCHINA};
private Command mapTypeCommand = new Command("MapType", Command.OK, 1);
public void startApp() {
init();
canvas.addCommand(mapTypeCommand);
canvas.setCommandListener(this);
GeoLatLng center = new GeoLatLng(32.0616667, 118.7777778);
map.setCenter(center, 13, MapType.GOOGLECHINA);
Display.getDisplay(this).setCurrent(canvas);
}
public void commandAction(Command c, Displayable d) {
if (c == mapTypeCommand) {
map.setMapType(mapTypes[mapType]);
mapType++;
mapType %= mapTypes.length;
}
}
}