2011-07-01 72 views
0

我想旋轉覆蓋項目(繪圖)根據我的軸承onLocationChanged。我該怎麼做呢?我試着用drawable,itemizedOverlay和overlayItem,但沒有成功。Android mapView:旋轉覆蓋項目

public void bearingRotation(float boatBearing){      
    Bitmap bm = ((BitmapDrawable)drawableCurrPos).getBitmap();   
    Matrix mat = new Matrix(); 
    mat.postRotate(boatBearing); 
    Bitmap bMapRotate = Bitmap.createBitmap(bm, 0, 0, bm.getWidth(),bm.getHeight(), mat, true); 

    drawableCurrPos = new BitmapDrawable(bMapRotate);      
} 

回答

0

我建議您將該drawable轉換爲位圖。

Bitmap bm = ((BitmapDrawable)drawable).getBitmap(); 
Matrix mat = new Matrix(); 
     mat.postRotate(90); 
     Bitmap bMapRotate = Bitmap.createBitmap(bm, 0, 0, bm.getWidth(),bm.getHeight(), mat, true); 

使用BitmapDrawable轉換此bMapRotate,並將其作爲指針指向您的位置。

+0

可否請您針對指針更精確一點? – Hannes

+0

這是否意味着我必須啓用位圖的分項疊加以及drawables? – Hannes

+0

@Hannes ..如果你能夠在地圖上顯示Overlay Item,那麼上面的代碼對於旋轉drawable是有用的。當你想旋轉drawable時,只需從Overlay Item中移除drawable。然後旋轉你的drawable(在上述情況下它旋轉了90度)。然後再次將該drawable添加到覆蓋項目。 – Harshad