Trouble with adding and displaying new route in GMap.NET WPF

Topics: Bugs, Help, WPF
May 8, 2013 at 5:55 PM
Edited May 8, 2013 at 6:00 PM
First of all, big thanks for your great maps! 8)))
Please, i need your help:
Whed adding new route in WPF (also in your example program) routes sometimes disappear from map... Can this cause of ZIndex? Or what? I noticed that the routes are poorly displayed when they cross each other. My opinion, this matters because of wrong "z order". Maybe i'm doing something wrong?
My code:
private List<PointLatLng> newRoutePoints = new List<PointLatLng>();
private bool creatingNewRoute = false;
void MainMap_MouseLeftButtonDown(object sender,System.Windows.Input.MouseButtonEventArgs e)
        {
            RoutingProvider rp = MainMap.MapProvider as RoutingProvider;
            MapRoute r;

            if (creatingNewRoute)
            {
                Point p = e.GetPosition(MainMap);
                newRoutePoints.Add(MainMap.FromLocalToLatLng((int)p.X, (int)p.Y));
                GMapMarker m = new GMapMarker(newRoutePoints.Last());

                m.Shape = new CustomMarkerDemo(this, m, GetGeo(m.Position));
                m.ZIndex = -2;
                MainMap.Markers.Add(m);
                //m.Shape
                //MainMap.Markers.Remove()
            }
            else if (!creatingNewRoute && newRoutePoints.Count >= 2)
            {
                r = new MapRoute(newRoutePoints, textBoxNewRouteName.Text);
         
                GMapMarker mRoute = new GMapMarker(newRoutePoints[0]);
                {
                    mRoute.Route.AddRange(r.Points);
                    mRoute.RegenerateRouteShape(MainMap);
                    (mRoute.Shape as System.Windows.Shapes.Path).Stroke = new SolidColorBrush(ColorPicker1.SelectedColor);
                    (mRoute.Shape as System.Windows.Shapes.Path).Width = 4;

                    mRoute.RegenerateRouteShape(MainMap);
                    mRoute.ZIndex = -1;
                }
                //MainMap.CreateRoutePath(newRoutePoints);
                MainMap.Markers.Add(new GMapMarker(newRoutePoints.First()));
                MainMap.Markers.Add(new GMapMarker(newRoutePoints.Last()));
                MainMap.Markers.Add(mRoute);
                newRoutePoints.Clear();
            }
            else
            {
                newRoutePoints.Clear();
            }
        }
Coordinator
May 8, 2013 at 6:11 PM
you have the code, make it work ;}
May 8, 2013 at 6:14 PM
Edited May 8, 2013 at 6:20 PM
radioman wrote:
you have the code, make it work ;}
So, it's bug or feauture? ;)
Does Windows Forms Gmap control more powerfull and stable, than WPF version?
May 13, 2013 at 9:41 AM
Edited May 13, 2013 at 9:42 AM
This is correct code:
(mRoute.Shape as System.Windows.Shapes.Path).Stroke = new SolidColorBrush(ColorPicker1.SelectedColor);
(mRoute.Shape as System.Windows.Shapes.Path).Stroke.Thickness= 4; // using Width is incorrect!