Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 2nd, 2012  |  syntax: None  |  size: 1.06 KB  |  hits: 20  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to access MyLocationOverlay's canvas?
  2. public boolean draw(android.graphics.Canvas canvas, MapView mapView, boolean shadow, long when)
  3. {
  4.     Log.v("Message", "Executing draw method...");        
  5.     boolean result;        
  6.     result = super.draw(canvas, mapView, shadow, when);
  7.  
  8.     if(geoLastFix != null) //geoLastFix contains the GeoPoint of my Location.
  9.     {
  10.         Point screenPts = mapView.getProjection().toPixels(geoLastFix, null);
  11.  
  12.         //rotate bitmap
  13.         Bitmap arrowBitmap = marker;
  14.         Matrix matrix = new Matrix();          
  15.         matrix.postRotate(orientation);
  16.         Bitmap rotatedBmp = Bitmap.createBitmap(
  17.             arrowBitmap,
  18.             0, 0,
  19.             arrowBitmap.getWidth(),
  20.             arrowBitmap.getHeight(),
  21.             matrix,
  22.             true
  23.         );
  24.        //print bitmap to canvas
  25.         canvas.drawBitmap(
  26.             rotatedBmp,
  27.             screenPts.x - (rotatedBmp.getWidth()  / 2),
  28.             screenPts.y - (rotatedBmp.getHeight() / 2),
  29.             null
  30.         );
  31.     }        
  32.     return result;
  33. }