Reputation: 35
I Need your help: I use GMap in Windows Presentation Foundation and i want to create a route with coordinates. It should be a route directly to the other coordinates, because it's a route for an airplane. Is there a function, that allows me to draw something like a line between my coordinates?
P.S. In a database are all the waypoints saved. The user only has to enter the waiponints Name and then the coordinates should be entered to the route.
Thanks for your help!
Upvotes: 1
Views: 562
Reputation: 1086
I will give you a demo to draw a line directly to the other coordinates like the below picture:
Create a list to for the marked points
List<PointLatLng> pointLatlngs = new List<PointLatLng>();
Add the marked points in the List when the point is marked
System.Windows.Point clickPoint = e.GetPosition(mapControl);
PointLatLng point = mapControl.FromLocalToLatLng((int)clickPoint.X, (int)clickPoint.Y);
pointLatlngs.Add(point);
Draw the line between points
for (int i = 0; i < pointLatlngs.Count; i++)
{
GMapRoute gmRoute = new GMapRoute(new List<PointLatLng>() {
pointLatlngs[i] , pointLatlngs.Count-1 == i ? pointLatlngs[i] : pointLatlngs[i + 1]})
{
Shape = new Line()
{
StrokeThickness = 3,
Stroke = System.Windows.Media.Brushes.BlueViolet
},
};
mapControl.Markers.Add(gmRoute);
}
Upvotes: 1