VB+MapX编程实现地图数据查询

前端之家收集整理的这篇文章主要介绍了VB+MapX编程实现地图数据查询前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

应用MapX控件实现查询功能并不太难。MapX为我们提供了Find、FindFeature等对象,可以用来实现我们需要的功能

1、本程序实现从下列表中选择一个节点,并以此节点为中心进行进行定位的功能(实例以第一层RTUName属性的值进行查询

Private Sub Command1_Click()
Dim FindObj As MapXLib。Find
Dim FoundFeature As FindFeature
‘从要查询的RTU图层生成Find对象,并为这个对象设置要查询的FindDataSet、FindField属性
Set FindObj = Form1。Map1。Layers。Item(1)。Find
Set FindObj。FindDataset = Form1。Map1。DataSets("RTU节点" " dataset")
Set FindObj。FindField = FindObj。FindDataset。Fields("RTUName")

Set FoundFeature = FindObj。Search(Combo1。Text)

Me。Hide
‘ 关掉AutoRedraw是因为CenterX(Y)的改变就要刷新图层,AutoRedraw打开的话会造成二次刷新
Form1。Map1。AutoRedraw = False
Form1。Map1。CenterX = FoundFeature。CenterX
Form1。Map1。CenterY = FoundFeature。CenterY
Form1。Show

End Sub

2、把上面的程序稍微改写一下,实现按照用户输入的字段进行查询定位的功能

Private Sub Command2_Click()

Dim FindObj As MapXLib。Find
Dim FoundFeature As FindFeature
‘从要查询的RTU图层生成Find对象,并为这个对象设置要查询的FindDataSet、FindField属性
Set FindObj = Form1。Map1。Layers。Item(1)。Find
Set FindObj。FindDataset = Form1。Map1。DataSets("RTU节点" " dataset")
Set FindObj。FindField = FindObj。FindDataset。Fields("RTUName")

Set FoundFeature = FindObj。Search(Text1。Text)

If FoundFeature。FindRC Mod 10 = 1 Or FoundFeature。FindRC Mod 10 = 2 Then
Me。Hide
‘ 关掉AutoRedraw是因为CenterX(Y)的改变就要刷新图层,AutoRedraw打开的话会造成二次刷新
Form1。Map1。AutoRedraw = False
Form1。Map1。CenterX = FoundFeature。CenterX
Form1。Map1。CenterY = FoundFeature。CenterY
Form1。Show
Else
MsgBox "不存在该RTU节点!"
End If

End Sub

猜你在找的VB相关文章