vb.net - 在 GMap 的 polyoverlays 中删除特定的多边形
问题描述
我正在尝试找到一种方法,让软件在天气警报超时时删除特定的多边形。
它创建得很好,但我在如何根据其名称/ID 删除它时遇到问题。
下面是代码。
Public Sub DrawPolygon(ByVal m As Integer, n As Integer)
' now draw on alert map
Dim i As Integer
Dim fld() As String
Dim dLat As Double, dLong As Double
Dim Red As String
Dim Green As String
Dim Blue As String
Dim plotColor As String
Dim dLatMax As Double = 0.0
Dim dLongMax As Double = -180.0
Dim dLatMin As Double = 90.0
Dim dLongMin As Double = 180.0
Dim drawColor As Color
For k = 0 To MasterNWSAlerts.Count - 1
If MasterNWSAlerts(k).inputalert.IndexOf(CountyDB(m).alertsTable(n).sAlert) <> -1 Then
Red = Val("&H" & Mid(MasterNWSAlerts(k).plotColor, 1, 2))
Green = Val("&H" & Mid(MasterNWSAlerts(k).plotColor, 3, 2))
Blue = Val("&H" & Mid(MasterNWSAlerts(k).plotColor, 5, 2))
plotColor = MasterNWSAlerts(k).plotColor
Exit For
End If
Next
drawColor = ConvertToRbg(plotColor)
fld = CountyDB(m).alertsTable(n).polygon.Split(" ")
Dim points = New List(Of PointLatLng)
For i = 0 To fld.Count - 1 Step 2
dLat = Val(fld(i)) / 100
dLong = (Val(fld(i + 1)) / 100) * -1
If dLat > dLatMax Then dLatMax = dLat
If dLong > dLongMax Then dLongMax = dLong
If dLat < dLatMin Then dLatMin = dLat
If dLong < dLongMin Then dLongMin = dLong
points.Add(New PointLatLng(dLat, dLong))
Next
dLat = Val(fld(0)) / 100
dLong = (Val(fld(1)) / 100) * -1
points.Add(New PointLatLng(dLat, dLong))
Dim polygon = New GMapPolygon(points, CountyDB(m).alertsTable(n).alertID)
polygon.Fill = New SolidBrush(Color.FromArgb(0, drawColor))
polygon.Stroke = New Pen(drawColor, 2)
polygon.IsHitTestVisible = True
polyOverlay.Polygons.Add(polygon)
GMapControl.Overlays.Add(polyOverlay)
' recenter map
If ConfigurationSettings.bAutoCenterAutoZoomEnabled Then
GMapControl.Position = CalculateCenterOfPolygon(points)
Dim rect As New RectLatLng(dLatMax, dLongMin, dLongMax - dLongMin, dLatMax - dLatMin)
GMapControl.SetZoomToFitRect(rect)
ConfigurationSettings.AlertMapCenterLatitude = dLat
ConfigurationSettings.AlertMapCenterLongitude = dLong
End If
' next commands force repaint
' GMapControl.Width += 1
' GMapControl.Width -= 1
GMapControl.Refresh()
ActivePolygons += 1
'fill in text box with latest alert
ToolStripStatusLabel1.Text = UCase(CountyDB(m).alertsTable(n).sAlert)
AlertMapTextBox.Text = CountyDB(m).alertsTable(n).detailedText
' now save off map into file
SaveAlertMapImage(CountyDB(m).alertsTable(n).alertID)
End Sub
Public Sub DeletePolygon(ByVal m As Integer, ByVal alertindex As Integer)
If CountyDB(m).alertsTable(alertindex).polygon <> vbNullString Then
*** this is where I am having the issue - how to selected the appropriate polygon within polyoverlay
Dim polygon = New GMapPolygon(CountyDB(m).alertsTable(alertindex).alertID)
'GMapControl.Overlays()
ActivePolygons -= 1
GMapControl.Refresh()
End If
End Sub
解决方案
推荐阅读
- javascript - 为什么我的导航栏没有在 Wordpress 中扩展?
- angular - 更新到 16.0.3 后泳道/ngx-datatable 不起作用(列似乎是问题所在)
- php - 使用 csrf_token 卷曲登录
- reactjs - 尝试使用 React-Spring 制作动画时出现错误“TypeError: rangeValue.replace is not a function”
- java - 如何使用用户创建的对象的变量?(Java)
- css - 带有粘性标题和粘性第一列的表格,但第一列的内容在标题下溢出 - 仅使用 CSS
- ipfs - 如何列出 IPFS 实例的所有当前固定文件?
- android - viewpager2 RTL 不适用于清单 supportRtl=false
- sql - 连接表上的 SQL 更新查询
- c# - 如何通过 C# 在 Sharepoint Online 中创建共享链接?