I am using Gmap.Net.Winforms to show the routes existing in a list on the routes path in my winform project. I show the routes path correctly on the map, but now I want to show the direction path by an arrow on those routes path too. I don't know how may I show the path from first point to the next one correctly on the path. I think maybe I should use the angle between two points, but no idea how to use it.
for (int i = 1; i < mainPoints.Count; i++)
{
double lat = (mainPoints[i - 1].Lat + mainPoints[i].Lat) / 2;
double lng = (mainPoints[i - 1].Lng + mainPoints[i].Lng) / 2;
double xDiff = mainPoints[i-1].Lat + mainPoints[i].Lat;
double yDiff = mainPoints[i-1].Lng + mainPoints[i].Lng;
double degree = Math.Atan2(yDiff, xDiff) * 180.0 / Math.PI;
GMarkerCross cm = new GMarkerCross(new PointLatLng(lat, lng));
cm.Pen = new Pen(System.Drawing.Color.Transparent);
cm.ToolTipText = ">";
cm.ToolTip.Offset = new System.Drawing.Point(0, 0);
cm.ToolTip.Font = new Font("Comic Sans MS", 25f, FontStyle.Bold | FontStyle.Italic);
cm.ToolTip.Foreground = new SolidBrush(System.Drawing.Color.Red);
cm.ToolTip.Fill = new SolidBrush(System.Drawing.Color.Transparent);
cm.ToolTipMode = MarkerTooltipMode.Always;
cm.ToolTip.Stroke = new Pen(System.Drawing.Color.Transparent);
markersLayer.Markers.Add(cm);
}
gmap.ZoomAndCenterRoute(route);
First select a suitable shape for showing direction, preferably with transparent background:
Then put this shape as custom marker at the mid-points. The selected shape direction is toward up which means zero rotation needed when bearing is zero (i.e. toward north pole).
Calculate mid-points:
Calculate Bearing:
Rotating Shape:
Sample Data:
Drawing the route with a direction inserted at mid-points of each segment and alignd to segment angle:
Result:
Zoomed View: