【问题标题】:Able to Show several location in blackberry maps but the position of maps is fixed. I am not able to zoom in and zoom out能够在黑莓地图中显示多个位置,但地图的位置是固定的。我无法放大和缩小
【发布时间】:2011-12-15 05:58:12
【问题描述】:

大家好,我尝试使用自定义 MapField 在地图上显示多个位置。我能够在地图上显示位置。但无法移动图像,也无法放大和缩小。我尝试使用自定义 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);
    }
}
}

【问题讨论】:

  • 您的目标操作系统版本是什么?
  • @jprofitt 版本 5 及以上。
  • 不幸的是,您必须自己实现缩放和平移。这是可能的(我已经做到了),但确实需要大量代码才能使其与触摸和滚轮设备一起使用。
  • 嘿,非常感谢......你能帮我一些代码吗

标签: blackberry maps


【解决方案1】:

为了放大和缩小我使用了这个-

 public boolean keyChar(char key, int status, int time) 
{    
    if(key=='i')
    {
        mMapField.setZoom(Math.max(mMapField.getZoom() - 1,mMapField.getMinZoom()));
    }
    else if(key=='o')
    {
        mMapField.setZoom(Math.min(mMapField.getZoom() + 1,mMapField.getMaxZoom()));
    }
    return super.keyChar(key, status, time);
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-03-11
    • 1970-01-01
    • 1970-01-01
    • 2013-08-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多