1

I'm trying to use something like a compass, passing it longitude/latitude values to let it point to a specific location, my code can draw an arrow while moving the phone (using GPS) to determine the location.

I want to use an image instead of the drawing thing

public void draw(Canvas canvas) {
        double angle = calculateAngle(currentLongitude, currentLatitude, targetLongitude, targetLatitude);
        //Correction;
        angle-=90;

    //Correction for azimuth
    angle-=azimuth;

    if((getContext() instanceof Activity) && ((Activity)getContext()).getWindowManager().getDefaultDisplay().getOrientation()==Configuration.ORIENTATION_PORTRAIT)angle-=90;

    while(angle<0)angle=angle+360;

    Rect rect = canvas.getClipBounds();

    int height = rect.bottom-rect.top;
    int width = rect.right-rect.left;
    int left = rect.left;
    int top = rect.top;

}
Lie Ryan
  • 62,238
  • 13
  • 100
  • 144
Reham
  • 1,916
  • 6
  • 21
  • 45
  • Do you want to implement a moving map ? – menjaraz Dec 17 '11 at 14:40
  • this code seems to be missing the part of the problem because its not drawing anything AND it contains other problems, like the while-loop where an if-case would be apropriate – NikkyD Dec 17 '11 at 14:56

1 Answers1

0

You need to do two things:

  1. Rotate the pointer image
  2. Draw the resulting bitmap to screen.

A few tricks, it might be faster to pre-rotate the image when your program starts up rather than rotating it every time you draw; however it would also take more memory.

Community
  • 1
  • 1
Lie Ryan
  • 62,238
  • 13
  • 100
  • 144