[英]How to draw a polygon on the Esri map using Selenium, Webdriver, C#
[英]How to draw colored routes on the google map using c#?
我正在制作 c# 应用程序。 我使用谷歌地图,我想用不同的颜色绘制两条路线。 例如:第一个我想是红色的,第二个是绿色的,但它们都是绿色的。 我想更改第二种颜色,使第一种颜色stay the same
。
这是我的代码:
PointLatLng start1 = new PointLatLng(42.252938, 42.680411);
PointLatLng end1 = new PointLatLng(42.256321, 42.675658);
GDirections dir1;
var path1 = GMapProviders.GoogleMap.GetDirections(out dir1, start1, end1, false, false, true, true, true);
GMapRoute route1 = new GMapRoute(dir1.Route, "path1");
route1.Stroke.Color = Color.Red;
GMapOverlay lay1 = new GMapOverlay("route1");
lay1.Routes.Add(route1);
map.Overlays.Add(lay1);
PointLatLng start2 = new PointLatLng(42.259188, 42.670733);
PointLatLng end2 = new PointLatLng(42.259617, 42.673362);
GDirections dir2;
var path2 = GMapProviders.GoogleMap.GetDirections(out dir2, start2, end2, false, false, true, true, true);
GMapRoute route2 = new GMapRoute(dir2.Route, "path2");
route2.Stroke.Color = Color.Green;
GMapOverlay lay2 = new GMapOverlay("route2");
lay2.Routes.Add(route2);
map.Overlays.Add(lay2);
不要尝试将 'route.Stroke.Color' 设置为颜色,而是将 'route.Stroke' 设置为新的 Pen(Color.Red)(例如)。
route1.Stroke = new System.Drawing.Pen(Color.Red);
这应该可以工作。
注意**(我认为它必须是一个“新”对象,因为绘制它的图形对象需要对指向它的静态颜色对象的引用,然后在更改 route.Stroke.Color 时更改了此引用再次使他们都画了绿色?!)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.