首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > BlackBerry >

Blackberry引路蜂map开发示例:选择map服务

2012-08-07 
Blackberry引路蜂地图开发示例:选择地图服务引路蜂地图服务缺省使用Google地图服务,但你也可以选择其它地

Blackberry引路蜂地图开发示例:选择地图服务

引路蜂地图服务缺省使用Google地图服务,但你也可以选择其它地图服务,比方说当Google服务离线时,您可以选择MapAbc的地图服务,另外要注意的是中国地图是有偏移的。如果想使用无偏移的中国地图,一是采用地图偏移校正算法,另外一个是使用CloudMade地图服务。
所前所述,引路蜂地图开发包在设计时将地图图片显示和地图服务两部分设计成相对独立的两部分,Google中国地图图片,Bing中国地图图片,MapAbc中国地图图片是有偏移的地图图片,CloudMade(OpenStreet)中国地图图片是无偏移的。而Google中国地图服务,MapAbc中国地图服务是有偏移,CloudMade地图服务是无偏移的。所以在选择地图类型和地图服务类型时,要么都选择有偏移,要么都选择无偏移。否则地图在显示路径时或地址时就不匹配。

下面列表是合法的组合:

地图类型 (MapType) 地图服务类型 (DigitalMapService)GOOGLECHINAGOOGLE_MAP_SERVICEMICROSOFTCHINAGOOGLE_MAP_SERVICEMAPABCCHINAGOOGLE_MAP_SERVICEOPENSTREETMAPCLOUDMADE_MAP_SERVICEGOOGLECHINAMAPABC_MAP_SERVICEMICROSOFTCHINAMAPABC_MAP_SERVICEMAPABCCHINAMAPABC_MAP_SERVICE

下述示列地图类型使用MICROSOFTCHINA,而使用不同的地图服务时路径查询的情况。(南京到天津的路径)

//--------------------------------- PACKAGE ------------------------------------ package com.pstreets.gisengine.demo.rim;   //--------------------------------- IMPORTS ------------------------------------ import com.mapdigit.gis.MapDirection; import com.mapdigit.gis.geometry.GeoLatLng; import com.mapdigit.gis.raster.MapType; import com.mapdigit.gis.service.IRoutingListener; import com.mapdigit.gis.service.DigitalMapService; import com.pstreets.gisengine.demo.MapDemoRIM; import net.rim.device.api.ui.component.Menu; import net.rim.device.api.ui.MenuItem;   //[------------------------------ MAIN CLASS ----------------------------------] /**  *  Map routing demo for Guidebee Map API on RIM platform.  * <hr><b>© Copyright 2011 Guidebee, Inc. All Rights Reserved.</b>  * @version     1.00, 10/02/11  * @author      Guidebee Pty Ltd.  */public class MapServiceTypeRIM extends MapDemoRIM implements      IRoutingListener {       /**      * 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.         MapServiceTypeRIM theApp = new MapServiceTypeRIM();               theApp.enterEventDispatcher();     }          private MenuItem mapGetDirectionMenuItem = new MenuItem("Get Direction", 0, 0){         public void run(){             GeoLatLng latLng1=new GeoLatLng(32.0418381,118.7788905);             GeoLatLng latLng2=new GeoLatLng(39.11643,117.180908);             map.getDirections(new GeoLatLng[]{latLng1,latLng2});         }     };       public MapServiceTypeRIM() {           init();         pushScreen(canvas);         //map.setCurrentMapService(DigitalMapService.GOOGLE_MAP_SERVICE);         //map.setCurrentMapService(DigitalMapService.MAPABC_MAP_SERVICE);          map.setCurrentMapService(DigitalMapService.CLOUDMADE_MAP_SERVICE);         map.setRoutingListener(this);         GeoLatLng center = new GeoLatLng(32.0616667, 118.7777778);                map.setCenter(center, 13, MapType.MICROSOFTCHINA);              }          public void done(String arg0, MapDirection result) {         if (result != null) {             map.setMapDirection(result);             //map.resize(result.getBound());            // map.setZoom(6);            map.setZoom(15);            map.panTo(result.routes[0].startGeocode.point);         }     }          protected void createMenu(Menu menu, int instance){          menu.add(mapGetDirectionMenuItem);      } }


 

Blackberry引路蜂map开发示例:选择map服务

上图分别为三种地图服务返回的路径,Google 地图服务和MapAbc地图服务返回的结果基本相同,实际上Google 地图服务在中国的地图是来自于MapAbc。而CloudMade地图返回的结果似乎偏移了道路。这是因为Bing 中国地图是被偏移过的,而CloudMade返回的无偏移的结果。Google 地图服务和MapAbc地图服务返回的结果也是偏移过的,所以和偏移过的地图很“匹配”。

Blackberry引路蜂地图开发包Ver2.1下载

热点排行