Java Android mapView:旋转覆盖项

Java Android mapView:旋转覆盖项,java,android,android-mapview,rotation,drawable,Java,Android,Android Mapview,Rotation,Drawable,我想根据我的方位位置更改,旋转一个可绘制的覆盖项目。我该怎么做?我试过用可拉丝的,用itemizedOverlay的,用overlayItem的,但没有成功 public void bearingRotation(float boatBearing){ Bitmap bm = ((BitmapDrawable)drawableCurrPos).getBitmap(); Matrix mat = new Matrix()

我想根据我的方位位置更改,旋转一个可绘制的覆盖项目。我该怎么做?我试过用可拉丝的,用itemizedOverlay的,用overlayItem的,但没有成功

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

我建议您将该绘图转换为位图

 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,并将其作为pin指针应用到您的位置。

能否请您对pin指针更精确一点?这是否意味着我必须为位图和Drawable启用逐项覆盖?@Hannes。。若你们们能够在地图上显示你们们的覆盖项目,那个么上面的代码对于旋转那个可绘制项目是很有用的。当你想旋转这个可绘制物体时,只需从覆盖项目中移除这个可绘制物体。然后旋转你的可绘制物体,在上面的情况下,它会旋转90度。然后再次添加可绘制到叠加项目。非常感谢您的帮助!我已经让它几乎工作了。当我尝试旋转可绘图的onLocationChanged时,只剩下一个bug:可绘图的旋转速度非常快,然后应用程序崩溃。这就是我在设置MapOverlay之前所称的OnLocation Changed:public void Bearing Rotation Float boatBearing{//根据方位位图bm=BitmapDrawabledrawableCurrPos.getBitmap旋转船;Matrix mat=new Matrix;mat.PostRotateBoatBeating;//mat.postRotategpsMath.getGpsBearing;Bitmap bMapRotate=Bitmap.createBitmapbm,0,bm.getWidth,bm.getHeight,mat,true;drawableCurrPos=new BitmapDrawablebMapRo泰特;}