2016-12-02 160 views
0

我正在使用Gmap.NET的WPF版本。在GMap.NET.WindowsPresentation中设置路线颜色

这感觉像一个愚蠢的问题....但我不知道如何改变路线的笔触颜色/宽度。

在WinForms的GMapRoute具有可设置为你所期望的

GMapRoute r = new GMapRoute(route.Points, "My route"); 
r.Stroke.Width = 2; 
r.Stroke.Color = Color.TurdBrown; 

的WPF版本似乎非常不同,我无法弄清楚产权行程。

回答

2

我可以使用浇铸访问这些属性,这里是我的代码:

所有我创建了GMapRoute的
GMapRoute mRoute = new GMapRoute(route.Points); 
mRoute.RegenerateShape(MainMap); 
((System.Windows.Shapes.Path)mRoute.Shape).Stroke = new SolidColorBrush(Colors.Red); 
((System.Windows.Shapes.Path) mRoute.Shape).StrokeThickness = 20; 

Firts,然后我产生它的形状在地图上,然后我修改了形状改变颜色和厚度。

我希望这可以帮助你。

0

我觉得使用RegenerateShape创建Shape对于性能不好。 在向地图添加路线之前,最好设置线条样式。

List<PointLatLng> routePath = List<PointLatLng>(); 
routePath.Add(new PointLatLng(Lat1,Lon1)); 
.... 
routePath.Add(new PointLatLng(LatN,LonN)); 
GMapRoute groute = new GMapRoute(routePath); 
groute.Shape = new Path() { Stroke = new SolidColorBrush(Colors.Red), StrokeThickness = 4 }; 
map.Markers.Add(groute);