查询图层.txt

来自「mapxtrexe查看地图,查询图层,按名查找等」· 文本 代码 · 共 33 行

TXT
33
字号
Dim _findLayerName As String = "Area"
        Dim find As MapInfo.Data.Find.Find = Nothing


        Try
            Dim map As Map = MapInfo.Engine.Session.Current.MapFactory(MapControl1.MapAlias)
            If (MapInfo.Engine.Session.Current.MapFactory.Count = 0) Then
                Return
            End If

            If (map Is Nothing) Then
                Return
            End If

            Dim findLayer As FeatureLayer = map.Layers(_findLayerName)

            find = New MapInfo.Data.Find.Find(findLayer.Table, findLayer.Table.TableInfo.Columns("Position"))
            Dim result As FindResult = find.Search(TextBox1.Text)
            If result.ExactMatch Then
                'Create a Feature(point) for the location we found.
                map.Center = New DPoint(result.FoundPoint.X, result.FoundPoint.Y)
                TextBox1.Text = "找到!"
            Else
                TextBox1.Text = "未找到!"
            End If

            find.Dispose()
        Catch ex As Exception
            TextBox1.Text = ex.Message
            If Not find Is Nothing Then
                find.Dispose()
            End If
        End Try

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?