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

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

package com.pstreets.gisengine.demo.midp; //--------------------------------- IMPORTS ------------------------------------ import com.mapdigit.gis.geometry.GeoLatLng; import com.mapdigit.gis.raster.MapType; import com.pstreets.gisengine.demo.MapDemoMIDP; import javax.microedition.lcdui.Command; import javax.microedition.lcdui.CommandListener; import javax.microedition.lcdui.Display; import javax.microedition.lcdui.Displayable; //[------------------------------ MAIN CLASS ----------------------------------] //--------------------------------- REVISIONS ---------------------------------- // Date Name Tracking # Description // -------- ------------------- ------------- -------------------------- // 28JAN2011 James Shen Initial Creation /** * map pan demo for Guidebee Map API on MIDP platform. */ public class MapPanMIDP extends MapDemoMIDP implements CommandListener { private Command mapUpCommand = new Command("Up", Command.OK, 1); private Command mapDownCommand = new Command("Down", Command.ITEM, 1); private Command mapLeftCommand = new Command("Left", Command.ITEM, 1); private Command mapRightCommand = new Command("Right", Command.ITEM, 1); public void startApp() { init(); canvas.addCommand(mapUpCommand); canvas.addCommand(mapDownCommand); canvas.addCommand(mapLeftCommand); canvas.addCommand(mapRightCommand); canvas.setCommandListener(this); GeoLatLng center = new GeoLatLng(32.0616667, 118.7777778); map.setCenter(center, 13, MapType.MICROSOFTCHINA); Display.getDisplay(this).setCurrent(canvas); } public void commandAction(Command c, Displayable d) { if (c == mapUpCommand) { map.panDirection(0, -32); } else if (c == mapDownCommand) { map.panDirection(0, 32); } else if (c == mapLeftCommand) { map.panDirection(-32, 0); } else if (c == mapRightCommand) { map.panDirection(32, 0); } } }


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值