我想知道如何使用我们自己的徽标来显示BBMap中的特定位置? 谁能知道怎么做?
I want to know how to use our own logo to show the particular place in BBMap? Can anyone knows how to do this ?
最满意答案
黑莓地图
在Blackberry Map中无法显示POI的自定义图标。 您可以在Blackberry地图上的位置中包含的内容:
位置的纬度* 100,000。 南方是消极的。 位置的经度* 100,000。 西方是消极的。 要在该位置旁边显示的标签。 BlackBerry智能手机用户选择时显示的说明 细节。 缩放级别从0到MAX_ZOOM。 地址 市 省或州 国家 邮政编码 电话 传真 网址 电子邮件地址 类别 评级信息介于0和5之间请参阅什么是 - BlackBerry Maps位置文档格式
另请参阅如何 - 调用BlackBerry Maps
使用MapField
作为替代方案,您可以尝试MapField + manager / screen paint override。
MapField的自定义扩展:
class CustomMapField extends MapField { Bitmap mIcon; XYRect mDest; public void moveTo(Coordinates coordinates) { super.moveTo(coordinates); mDest = null; } protected void paint(Graphics graphics) { super.paint(graphics); if (null != mIcon) { if (null == mDest) { XYPoint fieldOut = new XYPoint(); convertWorldToField(getCoordinates(), fieldOut); int imgW = mIcon.getWidth(); int imgH = mIcon.getHeight(); mDest = new XYRect(fieldOut.x - imgW / 2, fieldOut.y - imgH, imgW, imgH); } graphics.drawBitmap(mDest, mIcon, 0, 0); } } }使用示例:
class Scr extends MainScreen { CustomMapField mMapField; Coordinates mCoordinates; public Scr() { LocationProvider provider = null; Location location = null; try { provider = LocationProvider.getInstance(null); } catch (LocationException e) { e.printStackTrace(); } try { location = provider.getLocation(-1); } catch (LocationException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } mCoordinates = location.getQualifiedCoordinates(); add(new LabelField("Latitude: " + String.valueOf(Coordinates.convert( mCoordinates.getLatitude(), Coordinates.DD_MM_SS)))); add(new LabelField("Longitude: " + String.valueOf(Coordinates.convert( mCoordinates.getLongitude(), Coordinates.DD_MM_SS)))); mMapField = new CustomMapField(); mMapField.mIcon = Bitmap.getBitmapResource("poi_icon.png"); mMapField.moveTo(mCoordinates); add(mMapField); } }也可以看看 在Blackberry中使用MapComponent GPS和BlackBerry Maps开发指南
准备GPS数据
如果是真实设备,请确保GPS可用并打开。 如果是模拟器,那么在你开始程序之前使用模拟器菜单 - >模拟 - > GPS定位来设置GPS数据。 其他选项是硬编码您自己的Coordinats并在没有GPS的情况下使用它们:
double latitude = 51.507778; double longitude = -0.128056; Coordinates mCoordinates = new Coordinates(latitude, longitude, 0);BlackBerry Map
It's not possible in Blackberry Map to show custom icon for POI. Things you can include in Location on Blackberry Map:
The latitude of the location * 100,000. South is negative. The longitude of the location * 100,000. West is negative. The label to be displayed beside the location. The description displayed when the BlackBerry smartphone user selects details. Zoom level from 0 to MAX_ZOOM. Address City Province or state Country Postal code Phone Fax URL Email address Category Rating information between 0 and 5See What Is - BlackBerry Maps Location Document Format
Also see How To - Invoke BlackBerry Maps
Using MapField
As an alternative you can try MapField + manager/screen paint override.
Custom extension for MapField:
class CustomMapField extends MapField { Bitmap mIcon; XYRect mDest; public void moveTo(Coordinates coordinates) { super.moveTo(coordinates); mDest = null; } protected void paint(Graphics graphics) { super.paint(graphics); if (null != mIcon) { if (null == mDest) { XYPoint fieldOut = new XYPoint(); convertWorldToField(getCoordinates(), fieldOut); int imgW = mIcon.getWidth(); int imgH = mIcon.getHeight(); mDest = new XYRect(fieldOut.x - imgW / 2, fieldOut.y - imgH, imgW, imgH); } graphics.drawBitmap(mDest, mIcon, 0, 0); } } }Example of use:
class Scr extends MainScreen { CustomMapField mMapField; Coordinates mCoordinates; public Scr() { LocationProvider provider = null; Location location = null; try { provider = LocationProvider.getInstance(null); } catch (LocationException e) { e.printStackTrace(); } try { location = provider.getLocation(-1); } catch (LocationException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } mCoordinates = location.getQualifiedCoordinates(); add(new LabelField("Latitude: " + String.valueOf(Coordinates.convert( mCoordinates.getLatitude(), Coordinates.DD_MM_SS)))); add(new LabelField("Longitude: " + String.valueOf(Coordinates.convert( mCoordinates.getLongitude(), Coordinates.DD_MM_SS)))); mMapField = new CustomMapField(); mMapField.mIcon = Bitmap.getBitmapResource("poi_icon.png"); mMapField.moveTo(mCoordinates); add(mMapField); } }See also Using MapComponent in Blackberry GPS and BlackBerry Maps Development Guide
Prepare GPS data
If it's real device, be sure GPS is available and turned on. If it's simulator, then before you start program use simulator menu -> simulate -> GPS Location to set GPS data. Other option is hardcode your own Coordinats and use them without GPS:
double latitude = 51.507778; double longitude = -0.128056; Coordinates mCoordinates = new Coordinates(latitude, longitude, 0);
更多推荐
发布评论