Vaibhav Pandya
Vaibhav Pandya

Reputation: 125

How rotate custom moving marker (image) GMap

I have a marker(plane bug) on GMap which moves on a flight path but I want it to rotate when it turns. Is there any way of doing this in GMap C#?

Upvotes: 2

Views: 1500

Answers (1)

Vajura
Vajura

Reputation: 1132

You can use this function to rotate the image of the marker and then just reasign the marker with this image.

public Bitmap RotateImage(Image image, float angle)
{
    Bitmap rotatedBmp = new Bitmap(image.Width, image.Height);
    rotatedBmp.SetResolution(image.HorizontalResolution, image.VerticalResolution);
    Graphics g = Graphics.FromImage(rotatedBmp);
    PointF offset = new PointF(image.Width / 2, image.Height / 2);
    g.TranslateTransform(offset.X, offset.Y);
    g.RotateTransform(angle);
    g.TranslateTransform(-offset.X, -offset.Y);
    g.DrawImage(image, new PointF(0, 0));

    return rotatedBmp;
}   

you can just do it like this then

marker.img = RotateImage(innitialImg, xxx);

Upvotes: 2

Related Questions