2011-12-15 42 views
1

大家好,我嘗試使用Custom MapField在地圖上顯示幾個loacations。我可以在地圖上顯示位置。但是不能夠移動的圖像,並且還着放大和縮小out.i嘗試使用自定義的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); 
    } 
} 
} 
+0

你定位的操作系統版本是什麼? – jprofitt 2011-12-15 13:05:50

回答

1

在放大和縮小代碼out我用過這個 -

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