Changing route colors in WPF

Jan 12, 2010 at 10:58 AM

Hello,

Thanks for the great Gmaps project.

Q: Is there any way to change the color of the route from default navy in WPF?

I've seen there's a way, but only for Windows Forms. From what I have found it looks like the navy color is hard-coded into the library and the only way is to change the source code.

I don't have a good grasp of Dependency Properties - can it be done through them?

 

Kind regards,

Adam.

Jan 12, 2010 at 12:06 PM

yes you can change it, (route.Shape as System.Windows.Shapes.Path).Fill = Brushes.Red;

Jan 12, 2010 at 12:33 PM

(route.Shape as System.Windows.Shapes.Path).Fill = Brushes.Red; gives me an exception (System.Windows.Markup.XamlParseException).

 

So far, I modified the source code adding the Brush property to the GMapMarker class and passing this Brush to CreateRoutePath() function invoked by RegenerateRouteShape() in GMapMarker class.

In the body of CreateRoutePath() I changed the line "myPath.Stroke = Brushes.navy;" to "myPath.Stroke = brush;"

And that works. (The only problem is that I had to recompile the library)

 

And by the way:

1)How to achieve the red GoogleMaps marker with a shadow, like in the picture from codeproject: http://www.codeproject.com/KB/miscctrl/GMapNET/GMapNETv7cp.PNG

2) (Important) How did you manage to make the graph from http://jjvkug.blu.livefilestore.com/y1pLxH_8gtCggPiPzkZMOeOG6BJeH9AgCDUSD4OKK2HRWgZSUjgCNNcfS4wv3ooM6F2Dt7-V9KLrSXFBaxvo-LmvP9SQif83eyM/trolis-demo.png? (Did you use any special library for this, like Visifire or just WPF?)

Jan 12, 2010 at 12:40 PM

..strange, it should work as i said anyway. But do you call it After shape generation?

1) just render shadow image nexto marker, check winforms demo markers

2) http://dynamicdatadisplay.codeplex.com/

 

Jan 12, 2010 at 1:20 PM

Of course ;), I called it before route.RegenerateRouteShape(MainMap);

But Fill doesn't change the color. What works is Stroke: (route.Shape as System.Windows.Shapes.Path).Stroke = Brushes.Red;

So it looks like:

GMapMarker route= new GMapMarker(new PointLatLng(lat,lng));
route.Route.AddRange(Points); //(defined before)
route.RegenerateRouteShape(MainMap);
(route.Shape as System.Windows.Shapes.Path).Stroke = Brushes.Green;
route.ZIndex = -1;
MainMap.Markers.Add(route);

 

Thank you for your rapid help!

Adam

Jan 12, 2010 at 1:41 PM

welcome ;}