0

I have a mapview that has a custom item per OverlayItem and the class is here.

 class MapObject extends OverlayItem{

 String name;
 String heading;

 Drawable marker = null;

PlaneObject(GeoPoint pt, String name, String snippet, Drawable marker){
    super(pt,name,snippet);
    this.marker = marker;
}

@Override
public Drawable getMarker(int stateBitset){
    Drawable result = marker;
    setState(result,stateBitset);
    result.setBounds(-result.getIntrinsicWidth()/2, -result.getIntrinsicHeight(), result.getIntrinsicWidth() /2, 0);
    //Want to rotate the drawable to the angle stored in the heading variable
    return(result); 
}   

}

I would like to be able to rotate the Drawable by the heading within the class so when the mapView calls it then it will return the rotated drawable.

Lee Armstrong
  • 11,420
  • 15
  • 74
  • 122
  • Is this a simple rotation, or are you rotating the map and want to counter rotate the bitmap to match the maps new orientation. – Idistic Jul 19 '11 at 17:46

1 Answers1

1

Take a look at this (change the signature to actually return the drawable!)

Rotate Bitmap to Match Bearing

Community
  • 1
  • 1
Idistic
  • 6,281
  • 2
  • 28
  • 38
  • What do you mean change the signature? – Lee Armstrong Jul 19 '11 at 17:59
  • I just meant that his method had a return type of void and he was returning a drawable, anyway it should do what you want more or less – Idistic Jul 19 '11 at 20:02
  • That works great but it has shrunk them all, the graphic is 20px square normally and now it looks half of that at least! – Lee Armstrong Jul 20 '11 at 06:34
  • 1
    @Lee Armstrong - should not do that, well I will take a look, I suspect it's the intermediate step that does that, you can of course scale the bit map using another matrix op like matrix.postScale(scaleWidth, scaleHeight); but you should not need to – Idistic Jul 20 '11 at 14:09