Blackberry引路蜂地图开发示例:路径查询

来源:网络 责任编辑:栏目编辑 发表时间:2013-07-01 11:58 点击:

可以通过RasterMap的getDirection()方法来查询路径,和查询地址类似,路径查询的结果也是通过回调函数的方式来通知应用程序的,下面的例子返回南京到北京的路径。返回结果存放在MapDirection中,MapDirection包含了路径的详细信息,包括路径的每个步骤,长度,时间,方向等

[java]
//--------------------------------- 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.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 MapRoutingRIM 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.  
        MapRoutingRIM theApp = new MapRoutingRIM();       
        theApp.enterEventDispatcher(); 
    } 
     
    private MenuItem mapGetDirectionMenuItem = new MenuItem("Get Direction", 0, 0){ 
        public void run(){ 
            String name1 = "南京";            
            String name2 = "北京";            
            map.getDirections("from: " + name1 + " to: " + name2); 
        } 
    };  
  
    public MapRoutingRIM() {  
  
        init(); 
        pushScreen(canvas); 
        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) { 
      &nbs

    发表评论
    请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
    用户名: 验证码:点击我更换图片
    最新评论 更多>>

    推荐热点

    • cocos2d-x学习笔记(19)--label 、label atlas
    • cocos2d-x学习笔记(23)--地图的使用3--CCTMXLayer
    • Cocos2d-x学习(一):HelloWorld
    • cocos2dx在xcode下开发,编译到android上(2)
    • cocos2d 设置屏幕默认方向
    • cocos2d-x学习笔记(22)--地图的使用2(TMX) --Z-Order、AnchorPoi
    • Cocos2d-x 2.0 之 Actions “三板斧” 之一
    • cocos2d-x学习笔记(18)--游戏打包(windows平台)
    • cocos2d-x学习笔记(16)--spritesheet(精灵表单)
    网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
    Copyright © 2008-2015 计算机技术学习交流网. 版权所有

    豫ICP备11007008号-1