引路蜂地图服务缺省使用Google地图服务,但你也可以选择其它地图服务,比方说当Google服务离线时,您可以选择MapAbc的地图服务,另外要注意的是中国地图是有偏移的。如果想使用无偏移的中国地图,一是采用地图偏移校正算法,另外一个是使用CloudMade地图服务。
所前所述,引路蜂地图开发包在设计时将地图图片显示和地图服务两部分设计成相对独立的两部分,Google中国地图图片,Bing中国地图图片,MapAbc中国地图图片是有偏移的地图图片,CloudMade(OpenStreet)中国地图图片是无偏移的。而Google中国地图服务,MapAbc中国地图服务是有偏移,CloudMade地图服务是无偏移的。所以在选择地图类型和地图服务类型时,要么都选择有偏移,要么都选择无偏移。否则地图在显示路径时或地址时就不匹配。
下面列表是合法的组合:
地图类型 (MapType) | 地图服务类型 (DigitalMapService) |
GOOGLECHINA | GOOGLE_MAP_SERVICE |
MICROSOFTCHINA | GOOGLE_MAP_SERVICE |
MAPABCCHINA | GOOGLE_MAP_SERVICE |
OPENSTREETMAP | CLOUDMADE_MAP_SERVICE |
GOOGLECHINA | MAPABC_MAP_SERVICE |
MICROSOFTCHINA | MAPABC_MAP_SERVICE |
MAPABCCHINA | MAPABC_MAP_SERVICE |
下述示列地图类型使用MICROSOFTCHINA,而使用不同的地图服务时路径查询的情况。(南京到天津的路径)
//------------------------------------------------------------------------------
// COPYRIGHT 2011 GUIDEBEE
// ALL RIGHTS RESERVED.
// GUIDEBEE CONFIDENTIAL PROPRIETARY
/ REVISIONS
// Date Name Tracking # Description
// --------- ------------------- ---------- --------------------------
// 29JAN2011 James Shen Initial Creation
//--------------------------------- PACKAGE ------------------------------------
package com.pstreets.gisengine.demo.midp;
//--------------------------------- IMPORTS ------------------------------------
import com.mapdigit.gis.MapDirection;
import com.mapdigit.gis.geometry.GeoLatLng;
import com.mapdigit.gis.raster.MapType;
import com.mapdigit.gis.service.DigitalMapService;
import com.mapdigit.gis.service.IRoutingListener;
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 ----------------------------------]
//--------------------------------- REVISIONS ----------------------------------
// Date Name Tracking # Description
// -------- ------------------- ------------- --------------------------
// 29JAN2011 James Shen Initial Creation
/**
* Map service type demo for Guidebee Map API on MIDP platform.
* <hr><b>© Copyright 2011 Guidebee, Inc. All Rights Reserved.</b>
* @version 1.00, 29/01/11
* @author Guidebee Pty Ltd.
*/
public class MapServiceTypeMIDP extends MapDemoMIDP implements CommandListener,
IRoutingListener {
private Command mapGetDirectionCommand = new Command("Get Direction",
Command.OK, 1);
public void startApp() {
init();
map.setCurrentMapService(DigitalMapService.CLOUDMADE_MAP_SERVICE);
//map.setCurrentMapService(DigitalMapService.GOOGLE_MAP_SERVICE);
//map.setCurrentMapService(DigitalMapService.MAPABC_MAP_SERVICE);
canvas.addCommand(mapGetDirectionCommand);
map.setRoutingListener(this);
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 == mapGetDirectionCommand) {
GeoLatLng latLng1=new GeoLatLng(32.0418381,118.7788905);
GeoLatLng latLng2=new GeoLatLng(39.11643,117.180908);
map.getDirections(new GeoLatLng[]{latLng1,latLng2});
}
}
public void done(String query, MapDirection result) {
if (result != null) {
map.setMapDirection(result);
map.resize(result.getBound());
map.setZoom(3);
// map.setMapDirection(result);
// map.setZoom(15);
// map.panTo(result.routes[0].startGeocode.point);
}
}
}
上图分别为三种地图服务返回的路径,Google 地图服务和MapAbc地图服务返回的结果基本相同,实际上Google 地图服务在中国的地图是来自于MapAbc。而CloudMade地图返回的结果似乎偏移了道路。这是因为Bing 中国地图是被偏移过的,而CloudMade返回的无偏移的结果。Google 地图服务和MapAbc地图服务返回的结果也是偏移过的,所以和偏移过的地图很“匹配”。