Hi Emux, thanks for the reply. I am trying to achieve the feature of rotating the marker like in the Cruiser app. The location marker rotates smoothly at the GPS location and stays at its position even when the map is dragged. Can you please guide me on how can this be achieved (calculation for each component in its unit system) ? Here is my RotatingMarker class.
class RotatingMarker extends Marker {
private Bitmap bitmap;
private int horizontalOffset;
private LatLong latLong;
private int verticalOffset;
protected float degree = 0.0f;
protected float px = 0.0f;
protected float py = 0.0f;
public RotatingMarker(LatLong latLong, Bitmap bitmap, int horizontalOffset, int verticalOffset) {
super(latLong, bitmap, horizontalOffset, verticalOffset);
this.latLong = latLong;
this.bitmap = bitmap;
this.horizontalOffset = horizontalOffset;
this.verticalOffset = verticalOffset;
}
@Override
public synchronized void draw(BoundingBox boundingBox, byte zoomLevel, Canvas canvas, Point topLeftPoint) {
if (this.latLong == null || this.bitmap == null) {
return;
}
long mapSize = MercatorProjection.getMapSize(zoomLevel, this.displayModel.getTileSize());
double pixelX = MercatorProjection.longitudeToPixelX(this.latLong.longitude, mapSize);
double pixelY = MercatorProjection.latitudeToPixelY(this.latLong.latitude, mapSize);
int halfBitmapWidth = this.bitmap.getWidth() / 2;
int halfBitmapHeight = this.bitmap.getHeight() / 2;
int left = (int) (pixelX - topLeftPoint.x - halfBitmapWidth + this.horizontalOffset);
int top = (int) (pixelY - topLeftPoint.y - halfBitmapHeight + this.verticalOffset);
int right = left + this.bitmap.getWidth();
int bottom = top + this.bitmap.getHeight();
Rectangle bitmapRectangle = new Rectangle(left, top, right, bottom);
Rectangle canvasRectangle = new Rectangle(0, 0, canvas.getWidth(), canvas.getHeight());
if (!canvasRectangle.intersects(bitmapRectangle)) {
return;