简体   繁体   中英

Draw polyline in gmap.net

I want to draw polyline on map. I can't find any example or documentation. Could somone help?

// Initialize map:
gMap.MapProvider = GMap.NET.MapProviders.OpenStreetMapProvider.Instance;
GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerAndCache;
gMap.Position = new PointLatLng(53.44827,14.49152);

//somepoints
//point1 = new PointLatLng(53.44827,14.49152);
//point2 = new PointLatLng(53.44827,14.49152);
//point3 = new PointLatLng(53.44827,14.49152);

//draw polyline

1)Create two lat,long points ie startLat,startLong & endLat,endLong

2)then use following code

Dim polygonPoints1 As List(Of PointLatLng) = New List(Of PointLatLng)
polygonPoints1.Add(New PointLatLng(startLat, startLong ))
polygonPoints1.Add(New PointLatLng(endLat, endLong))

r = New GMap.NET.WindowsForms.GMapRoute(polygonPoints1, "MyRoute")

r.Stroke.DashStyle = Drawing2D.DashStyle.Dash
Dim routesOverlay As GMapOverlay = New GMapOverlay("routes")
routesOverlay.Routes.Add(r)
Me.myMap.Overlays.Add(routesOverlay)

Hope this resolves your issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM