2016-12-02 158 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);