2011-07-01 75 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