Question

Let me start by saying that I have seen this thread: How can I replace the Compass image of MyLocationOverlay?

According to that thread, it tells me that I can't override the icon.

Not a big deal. That said, I'm trying to figure out a way to implement this.

Would I be correct in saying that I would need to create my own custom canvas that would simply draw the icon and rotate it and override the drawcompass method in another custom class that extends MyLocationOverlay?

If that is correct, how do I create this custom canvas of the icon/rotate it? (I have no experience with drawing in the android os).

Was it helpful?

Solution

Didn't need to make my own custom canvas, only had to override the drawCompass method, so it appears that the information in the initial question I linked was incorrect:

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

    Bitmap arrowBitmap = BitmapFactory.decodeResource( mContext.getResources(), R.drawable.compass);
      Matrix matrix = new Matrix();
        matrix.postRotate(bearing);
        Bitmap rotatedBmp = Bitmap.createBitmap(
            arrowBitmap, 
            0, 0, 
            arrowBitmap.getWidth(), 
            arrowBitmap.getHeight(), 
            matrix, 
            true
        );

        canvas.drawBitmap(rotatedBmp, 20, 20, null );
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top