Rotate marker

Topics: Windows Forms
Oct 14, 2011 at 8:28 AM

Please help me.

I want to turn the handle. Instead of the standard marker image I uploaded my. Now we need to handle rotated at different angles.

Anton from Russia.

Coordinator
Oct 14, 2011 at 8:18 PM

check the demo markers they support rotation

Oct 15, 2011 at 9:36 AM

What method provides the rotation?

Coordinator
Oct 15, 2011 at 9:46 AM

check the code

Oct 22, 2011 at 12:16 AM

where are those demo markers ??

Coordinator
Oct 22, 2011 at 8:23 AM

open the eyes ;}

Feb 23, 2012 at 8:04 PM

Hi

To make Custom marker from image and rotate it , use this code in c#

public class GMapMarkerImage : GMapMarker
    {
        public System.Drawing.Image Image;
        public double Heading;

        public GMapMarkerImage(PointLatLng p): base(p)
        {
        }

        public override void OnRender(Graphics g)
        {
            Point Aircraft_Position = new Point(LocalPosition.X - 32, LocalPosition.Y - 32);
            Point Center = new Point(Aircraft_Position.X + 32, Aircraft_Position.Y + 32);
            Rotate_Image(g, Exam_GMap.Properties.Resources.Airplane_64, Aircraft_Position, Center, (float)Heading, 1);
        }

        protected void Rotate_Image(Graphics pe, Image img, Point ptImg, Point ptRot, float angle_deg, float scaleFactor)
        {
            double beta = 0;     // Angle between the Horizontal line and the line (Left upper corner - Rotation point)
            double d = 0;        // Distance between Left upper corner and Rotation point)       
            float deltaX = 0;    // X componant of the corrected translation
            float deltaY = 0;    // Y componant of the corrected translation

            double angle_rad = (angle_deg * Math.PI / 180);
            // Compute the correction translation coeff
            if (ptImg != ptRot)
            {
                //
                if (ptRot.X != 0)
                {
                    beta = Math.Atan((double)ptRot.Y / (double)ptRot.X);
                }

                d = Math.Sqrt((ptRot.X * ptRot.X) + (ptRot.Y * ptRot.Y));

                // Computed offset
                deltaX = (float)(d * (Math.Cos(angle_rad - beta) - Math.Cos(angle_rad) * Math.Cos(angle_rad + beta) - Math.Sin(angle_rad) * Math.Sin(angle_rad + beta)));
                deltaY = (float)(d * (Math.Sin(beta - angle_rad) + Math.Sin(angle_rad) * Math.Cos(angle_rad + beta) - Math.Cos(angle_rad) * Math.Sin(angle_rad + beta)));
            }

            // Rotate image support
            pe.RotateTransform(angle_deg);

            // Dispay image
            pe.DrawImage(img, (ptImg.X + deltaX) * scaleFactor, (ptImg.Y + deltaY) * scaleFactor, img.Width * scaleFactor, img.Height * scaleFactor);

            // Put image support as found
            pe.RotateTransform(-angle_deg);

        }
    }

Feb 25, 2012 at 6:17 PM
Edited Feb 27, 2012 at 8:36 PM

hey j_sadi

i used yur class the marker rotate , but it get a new location 

can u plz help me

Coordinator
Jan 15, 2015 at 3:20 PM
rotation is fixed

p.s. marker rotation demo [left menu, Live->FlightRadar] and GMarkerArrow.cs