How to show our own icon in BlackBerry Map?

2020-01-29 18:27发布

I want to know how to use our own logo to show the particular place in BBMap? Can anyone knows how to do this ?

1条回答
Animai°情兽
2楼-- · 2020-01-29 19:18

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 5

See 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);
查看更多
登录 后发表回答