
Untitled
By: a guest on
May 2nd, 2012 | syntax:
None | size: 1.06 KB | hits: 20 | expires: Never
How to access MyLocationOverlay's canvas?
public boolean draw(android.graphics.Canvas canvas, MapView mapView, boolean shadow, long when)
{
Log.v("Message", "Executing draw method...");
boolean result;
result = super.draw(canvas, mapView, shadow, when);
if(geoLastFix != null) //geoLastFix contains the GeoPoint of my Location.
{
Point screenPts = mapView.getProjection().toPixels(geoLastFix, null);
//rotate bitmap
Bitmap arrowBitmap = marker;
Matrix matrix = new Matrix();
matrix.postRotate(orientation);
Bitmap rotatedBmp = Bitmap.createBitmap(
arrowBitmap,
0, 0,
arrowBitmap.getWidth(),
arrowBitmap.getHeight(),
matrix,
true
);
//print bitmap to canvas
canvas.drawBitmap(
rotatedBmp,
screenPts.x - (rotatedBmp.getWidth() / 2),
screenPts.y - (rotatedBmp.getHeight() / 2),
null
);
}
return result;
}