如何在 BlackBerry Map 中显示我们自己的图标? [英] How to show our own icon in BlackBerry Map?

查看:24
本文介绍了如何在 BlackBerry Map 中显示我们自己的图标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何使用我们自己的标志来显示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 Map 上的位置中包含的内容:

BlackBerry Map

It's not possible in Blackberry Map to show custom icon for POI.
Things you can include in Location on Blackberry Map:

  • 位置的纬度 * 100,000.南是负数.
  • 位置的经度 * 100,000.West 是否定的.
  • 要显示在位置旁边的标签.
  • BlackBerry 智能手机用户选择时显示的说明
    详情.
  • 缩放级别从 0 到 MAX_ZOOM.
  • 地址
  • 城市
  • 省或州
  • 国家
  • 邮政编码
  • 电话
  • 传真
  • 网址
  • 电子邮件地址
  • 类别
  • 0 到 5 之间的评分信息

请参阅 什么是 - 黑莓地图位置文档格式

另请参阅 如何 - 调用黑莓地图

作为替代方案,您可以尝试 MapField + 管理器/屏幕绘制覆盖.

As an alternative you can try MapField + manager/screen paint override.

MapField 的自定义扩展:

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

使用示例:

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

另见
在黑莓中使用 MapComponent
GPS 和 BlackBerry 地图开发指南

如果是真实设备,请确保 GPS 可用且已打开.
如果是模拟器,那么在你开始程序之前使用模拟器菜单 -> 模拟 -> GPS 位置来设置 GPS 数据.
其他选项是硬编码您自己的坐标并在没有 GPS 的情况下使用它们:

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

这篇关于如何在 BlackBerry Map 中显示我们自己的图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆