Draw polyline in gmap.net

5.4k views Asked by At

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

There are 1 answers

0
Mandar On

1)Create two lat,long points i.e. 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.