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

Blackberry引路蜂地图开发示例:地图平移

RasterMap 有两个方法可以用于平移地图,panTo 将地图移动到指定经纬度坐标,panDirection(dx,dy) 将地图从当前位置平移dx,dy 个象素。
下列示例可以上,下,左,右平移地图。

[java] 
//--------------------------------- PACKAGE ------------------------------------  
package com.pstreets.gisengine.demo.rim; 
  
//--------------------------------- IMPORTS ------------------------------------  
import com.mapdigit.gis.geometry.GeoLatLng; 
import com.mapdigit.gis.raster.MapType; 
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 MapPanRIM extends MapDemoRIM  { 
  
   /**
     * 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.  
        MapPanRIM theApp = new MapPanRIM();       
        theApp.enterEventDispatcher(); 
    } 
     
    private MenuItem mapUpMenuItem = new MenuItem("Up", 0, 0){ 
        public void run(){ 
            map.panDirection(0, -32); 
  
            }}; 
    private MenuItem mapDownMenuItem = new MenuItem("Down",1, 0){ 
        public void run(){ 
            map.panDirection(0, 32); 
            }}; 
    private MenuItem mapLeftMenuItem = new MenuItem("Left",2, 0){ 
        public void run(){ 
            map.panDirection(-32, 0); 
            }}; 
    private MenuItem mapRightMenuItem = new MenuItem("Right", 3, 0){ 
        public void run(){ 
            map.panDirection(32, 0); 
            }}; 
  
    public MapPanRIM() { 
  
        init(); 
        pushScreen(canvas); 
        GeoLatLng center = new GeoLatLng(32.0616667, 118.7777778); 
        map.setCenter(center, 13, MapType.MICROSOFTCHINA); 
  
    } 
  
    protected void createMenu(Menu menu, int instance){ 
         menu.add(mapUpMenuItem); 
         menu.add(mapDownMenuItem); 
         menu.add(mapLeftMenuItem); 
         menu.add(mapRightMenuItem); 
  
    } 


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