开发者

Android mapView: rotate overlay item

开发者 https://www.devze.com 2023-03-17 06:03 出处:网络
I want to rotate an overlay item (a drawable) according to my bearing onLocationChanged. How do I do this? I tried with the drawable, with the itemizedOverlay, and with the overlayItem, but no success

I want to rotate an overlay item (a drawable) according to my bearing onLocationChanged. How do I do this? I tried with the drawable, with the itemizedOverlay, and with the overlayItem, but no success.

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

    drawableCurrPos = new BitmapDrawable(bMapRotate);                       
}


I would suggest that you convert that drawable to bitmap.

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

Convert this bMapRotate using BitmapDrawable and apply that as a pin pointer to your location.

0

精彩评论

暂无评论...
验证码 换一张
取 消