您的位置:首页 > 其它

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

2012-07-24 10:22 281 查看
RasterMap 有两个方法可以用于平移地图,panTo 将地图移动到指定经纬度坐标,panDirection(dx,dy) 将地图从当前位置平移dx,dy 个象素。

下列示例可以上,下,左,右平移地图。

//--------------------------------- 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);
 
    }
}


Blackberry引路蜂地图开发包Ver2.1下载
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: