Using new version of mapsforge 0.5.1, map rotates fine with onSensorChanged event. I have added a custom GPS location marker at GPS point on onLocationChanged event. When the map rotates, the marker is also rotated to point towards the device heading like in google maps using the following code in the marker's draw method.
android.graphics.Canvas androidCanvas = AndroidGraphicFactory.getCanvas(canvas);
androidCanvas.save();
Float px = (float) canvas.getWidth()/2;
Float py = (float) canvas.getHeight()/2;
androidCanvas.rotate(degree, px, py);
canvas.drawBitmap(bitmap, left, top);
androidCanvas.restore();
However when the map is dragged, the marker's position disorients from the previous point of the GPS location.
How do I calculate the px and py value to keep the marker at the precise point of GPS location on map even when the map is rotating and also the marker pointing to the device heading.
I know it is a bit old, but for future researches i found a solution :
Replace this :
With this :
In my case "bearing" is a member variable of my class extenting Marker, that i set from 2 different locations earlier in code (gps location). you can replace it with any angle that suits your needs.