Marker rotate on heading

Topics: Windows Forms
May 31, 2011 at 3:03 PM

I am working on a WindowsForms application. I want to be able to draw a marker on the map that updates on GPS data updating the location of the marker on the map, at the same time I would like to (hopefully) draw a line showing the route that it took. In addition, I would like this marker to rotate depending on heading information such that if the vehicle is moving with a southeast heading, the arrow-like marker will be pointing to the bottom right of the map. Could someone help me as to how to accomplish that? I read some dicsussions about the map rotating, but I don't want the map to rotate, rather I want the marker to rotate and the map to remain static. Any help would be appreciated.

Coordinator
May 31, 2011 at 5:47 PM

so whats the problem?

May 31, 2011 at 6:13 PM

It's not a problem; rather I am trying to figure out what the best way to rotate the marker is. I saw that Marker had a Bearing variable, but I can't seem to access it by   marker.Bearing =  and I was wondering if that could be used for what I am trying to do, and if not, to find out what the best way was to accomplish that.

Also, I was wondering what the best way to do a path is. Should I simply create a new route and add points when I get a new GPS position?

Coordinator
May 31, 2011 at 6:20 PM

well, you have to experiment

Jun 1, 2011 at 1:10 PM
This is exactly what I do. Here is the code of my marker. Bearing property is define inside the marker class. Bearing is expressed in degrees (0.0 - 359.9 deg) . Good luck
public class FocusedCoordMarker : GMapMarker
    {

        public FocusedCoordMarker(PointLatLng pos)
            :base(pos)
        {
            Size = Properties.Resources.CurrentCoordMarker2.Size; // image resource
            Offset = new Point(-16, -16); // image is 32 x 32, offset to center of arrow image
        }

        public double Bearing { get; set; } // define bearing property in the marker class

        public override void OnRender(System.Drawing.Graphics g)
        {
            g.RotateTransform(Convert.ToSingle(Bearing));
            g.TranslateTransform(LocalPosition.X+Size.Width/2, LocalPosition.Y+Size.Height/2,System.Drawing.Drawing2D.MatrixOrder.Append);
                
            g.DrawImage(Properties.Resources.CurrentCoordMarker2, -Size.Width/2, -Size.Height/2, Size.Width, Size.Height);
            g.ResetTransform();
            
        }
    }