在 gmap.net 中绘制折线

本文关键字:绘制 折线 net gmap | 更新日期: 2023-09-27 17:55:40

我想在地图上画折线。我找不到任何示例或文档。索蒙能帮忙吗?

// 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

在 gmap.net 中绘制折线

1)创建两个纬度,长点,即开始纬度,开始长和结束纬度,结束长

2)然后使用以下代码

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)

希望这可以解决您的问题。