当前位置:编程学习 > wap >>

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

引路蜂地图API中同样提供了地址查询,路径查询,本地搜索,IP地址查询,地址反编码(通过经纬度查地名)等。 地址查询(或称为地址编码)是将输入的地名(如南京林业大学)转换成对应的经纬度坐标然后将其显示在地图上

[java]
//--------------------------------- PACKAGE ------------------------------------  
package com.pstreets.gisengine.demo.rim; 
  
//--------------------------------- IMPORTS ------------------------------------  
import com.mapdigit.gis.MapPoint; 
import com.mapdigit.gis.geometry.GeoLatLng; 
import com.mapdigit.gis.raster.MapType; 
import com.mapdigit.gis.service.IGeocodingListener; 
import com.pstreets.gisengine.demo.MapDemoRIM; 
import net.rim.device.api.ui.component.Menu; 
import net.rim.device.api.ui.MenuItem; 
//[------------------------------ MAIN CLASS ----------------------------------]  
/**
 *  map pan demo for Guidebee Map API on MIDP platform.
 * <hr><b>© Copyright 2011 Guidebee, Inc. All Rights Reserved.</b>
 * @version     1.00, 09/02/11
 * @author      Guidebee Pty Ltd.
 */ 
public class MapGeocodingRIM extends MapDemoRIM implements  IGeocodingListener { 
  
    /**
     * Entry point for application  www.zzzyk.com
     * @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.  
        MapGeocodingRIM theApp = new MapGeocodingRIM();       
        theApp.enterEventDispatcher(); 
    } 
     
    private MenuItem mapFindAddressMenuItem = new MenuItem("Find Address", 0, 0){ 
        public void run(){ 
            map.getLocations("南京林业大学"); 
        } 
    }; 
  
    public MapGeocodingRIM() { 
  
        init(); 
        pushScreen(canvas); 
        map.setGeocodingListener(this); 
       GeoLatLng center = new GeoLatLng(32.0616667, 118.7777778);        
        map.setCenter(center, 13, MapType.MICROSOFTCHINA); 
         
    } 
  
    
    public void done(String arg0, MapPoint[] result) { 
        if (result != null) { 
            map.panTo(result[0].getPoint()); 
        } 
    } 
     
    protected void createMenu(Menu menu, int instance){ 
         menu.add(mapFindAddressMenuItem); 
  
                        } 

//--------------------------------- PACKAGE ------------------------------------
package com.pstreets.gisengine.demo.rim;
 
//--------------------------------- IMPORTS ------------------------------------
import com.mapdigit.gis.MapPoint;
import com.mapdigit.gis.geometry.GeoLatLng;
import com.mapdigit.gis.raster.MapType;
import com.mapdigit.gis.service.IGeocodingListener;
import com.pstreets.gisengine.demo.MapDemoRIM;
import net.rim.device.api.ui.component.Menu;
import net.rim.device.api.ui.MenuItem;
//[------------------------------ MAIN CLASS ----------------------------------]
/**
 *  map pan demo for Guidebee Map API on MIDP platform.
 * <hr><b>© Copyright 2011 Guidebee, Inc. All Rights Reserved.</b>
 * @version     1.00, 09/02/11
 * @author      Guidebee Pty Ltd.
 */
public class MapGeocodingRIM extends MapDemoRIM implements  IGeocodingListener {
 
    /**
     * 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.
        MapGeocodingRIM theApp = new MapGeocodingRIM();     
        theApp.enterEventDispatcher();
    }
   
    private MenuItem mapFindAddressMenuItem = new MenuItem("Find Address", 0, 0){
        public void run(){
            map.getLocations("南京林业大学");
        }
    };
 
    public MapGeocodingRIM() {
 
        init();
        pushScreen(canvas);
        map.setGeocodingListener(this);
       GeoLatLng center = new GeoLatLng(32.0616667, 118.7777778);      
        map.setCenter(center, 13, MapType.MICROSOFTCHINA);
       
    }
 
  
    public void done(String arg0, MapPoint[] result) {
        if (result != null) {
            map.panTo(result[0].getPoint());
        }
    }
   
    protected void createMenu(Menu menu, int instance){
         menu.add(mapFindAddressMenuItem);
 
                        }
}所有的地图服务都是采用异步方式调用,在调用RasterMap.getLocation(address)前,需要设置好返回结果时的回调函数RasterMap.setGeocodingListener,回调函数接口定义为IGeocodingListener。 回调方法为public void done(String query,MapPoi

补充:移动开发 , 其他 ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,