Monday, October 10, 2011

[android-developers] Custom compass image bounds in subclassed MyLocationOverlay

I'd like to draw my own compass image on a MapView by subclassing
MyLocationOverlay. The custom image needs to be larger than the
default image shown by MyLocationOverlay. I override drawCompass and
use my own drawables (bitmaps) to draw the compass, however the bounds
of the canvas normally presented to drawCompass are too small:

@Override
protected void drawCompass(Canvas canvas, float bearing) {

Rect bounds = canvas.getClipBounds();
// usual result: bottom=98, left=10, right=90, top=18

// draw something custom here...

// Don't want default compass image:
//super.drawCompass(canvas, bearing);

}

How do you set the bounds of the custom imagery so that calls to
drawCompass set the required bounds on the canvas object? I'm guessing
that the bounds I'm seeing are those applicable to the default
imagery.

(drawCompass appears to be called from MyLocationOverlay.draw() - I
can override that, but am still unsure how to change the ClipBounds on
the canvas object).

Thanks for any help!

Stephen

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment