Showing posts with label heading Marker. Show all posts
Showing posts with label heading Marker. Show all posts

Friday, June 8, 2018

Tutorial C# Rotate GMAP.NET Marker from Heading IMU or digital Compass

If you have a marker on Google Map which moves on a flight path/ road track but you want it to rotate when it turns. To rotate the image marker Icon from GMap.NET C#, in first create new class, add public class function named "GMapMarkerPlane"


For icon picture, create the icon and add it into resource folder.


              private readonly Bitmap icon = Resources.planetracker;

In the declaration, create new layer name from GMapOverlay:

             public static GMapOverlay routesoverlay;

Next, in main form create new layer and add it to the gmap:

            routesoverlay = new GMapOverlay("routes");
            gMap.Overlays.Add(routesoverlay);

and then, add the code below in the GPS heading function (use timer 1 second or more):

            routesoverlay.Markers.Clear();

            // Get the most up-to-date data received from the sensor.
            var curMeas = vn200.CurrentMeasurements;

            PointLatLng point = new PointLatLng((float)curMeas.LatitudeLongitudeAltitude.X,
                                                                           (float)curMeas.LatitudeLongitudeAltitude.Y);
            gMap.Position = point;

            var plane = new GMapMarkerPlane(point, (float)curMeas.YawPitchRoll.YawInDegs);
            routesoverlay.Markers.Add(plane);

and finally, the Plane Marker heading will following your heading data sensor.


Keyword: Rotate GMap.NET marker, C#, heading Marker, IMU, google map marker, GPS tracking heading marker.