Draw a polyline in WPF

Topics: WPF
Jul 28, 2010 at 7:34 AM



I would like to draw some polylines on the map, from a list of PointLatLng items (every point of the list has to be linked to the previous point with a straight line).

I've found some examples in other threads, but they were Windows Forms specific (using overlays). Could someone give me some directions on how to do this in WPF ?



Jul 28, 2010 at 4:33 PM
there is demo for wpf, check the source
Jul 29, 2010 at 7:23 AM

Hi radioman,


In the wpf demo, you can ask google to calculate a route between two points (start and end), but I have not seen an option to make a polyline.

Maybe it's in the new Hot Build, but my computer fail to install it (system.data.sqlite not in global assembly cache).


Let's say I've got a list of 10 points (PointLatLng), each point of the list has to be connected to the next point with a straight line. There is a Polyline class in System.Windows.Shapes, but I don't know how to use it with the GMapControlNew class.

I need this to display the path taken by vechicles.




Jul 29, 2010 at 11:59 AM
Edited Jul 29, 2010 at 12:35 PM

I've found the answer, you were right, it was in the demo =)


Here's the code for those who are interested :



private void DrawPolyline(List<PointLatLng> coords, string name)


MapRoute path = new MapRoute(coords, name);
GMapMarker mRoute = new GMapMarker(coords[0]);
mRoute.ZIndex = -1;




Problem solved !