Blackberry引路蜂地圖開發樣本:本地查詢

來源:互聯網
上載者:User

本地查詢可以查詢指定地區內諸如賓館,郵局等使用者感興趣的地方。其使用方法和地址查詢非常類似。
下面樣本查詢32.0616667, 118.7777778為中心點一定地區內賓館的資訊

[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 MapLocalSearchRIM 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.  
        MapLocalSearchRIM theApp = new MapLocalSearchRIM();        
        theApp.enterEventDispatcher(); 
    } 
      
    private MenuItem mapFindAddressMenuItem = new MenuItem("Find Address", 0, 0){ 
        public void run(){ 
            String name = "賓館";                  
            GeoLatLng screenCenter = map.getScreenCenter();                 
            map.getLocations(name, 0, screenCenter,                         
            map.getScreenBounds(screenCenter));  
        } 
    }; 
  
    public MapLocalSearchRIM() { 
  
        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());             
            for (int i = 0; i < result.length; i++) {                 
                System.out.println(result[i].objectNote);             
             }         
         }  
    } 
      
    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 MapLocalSearchRIM 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.
        MapLocalSearchRIM theApp = new MapLocalSearchRIM();      
        theApp.enterEventDispatcher();
    }
    
    private MenuItem mapFindAddressMenuItem = new MenuItem("Find Address", 0, 0){
        public void run(){
            String name = "賓館";                
            GeoLatLng screenCenter = map.getScreenCenter();               
            map.getLocations(name, 0, screenCenter,                       
            map.getScreenBounds(screenCenter));
        }
    };
 
    public MapLocalSearchRIM() {
 
        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());           
            for (int i = 0; i < result.length; i++) {               
                System.out.println(result[i].objectNote);           
             }       
         }
    }
    
    protected void createMenu(Menu menu, int instance){
         menu.add(mapFindAddressMenuItem);
   }
}本地查詢方法
public void getLocations(String address,int start,GeoLatLng center,GeoBounds bound, IGeocodingListener listener);
指定中心點和查詢地區。本地查詢可以多次返回結果,start為查詢結果起始順序,每次返回結果在SearchOptions 中定義,預設每次返回4個。
上述結果返回內容為,具體結果可能不同。www.2cto.com
“晶麗酒店025-83310818 025-83310818212223 025-86636636 ”
“城市名人酒店025-83123333 025-83123888 ”
“南京玄武飯店 025-83358888 ”
“Sofitel Galaxy Nanjing – 南京索菲特銀河大酒店025-83718888 “

 

作者:mapdigit

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.