0、综述 应用MapX控件实现查询的功能并不太难。MapX为我们提供了Find、FindFeature等对象,可以用来实现我们需要的功能:) 1、本程序实现从下列表中选择一个节点,并以此节点为中心进行进行定位的功能(实例以第一层RTUName属性的值进行查询) Private Sub Command1_Click() Private Sub Command2_Click() Dim FindObj As MapXLib.Find
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、把上面的程序稍微改写一下,实现按照用户输入的字段进行查询定位的功能:
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
文章来源于领测软件测试网 https://www.ltesting.net/
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备10010545号-5
技术支持和业务联系:info@testage.com.cn 电话:010-51297073