考试必考mapobjects特征查找

上传人:ji****n 文档编号:45698966 上传时间:2018-06-18 格式:DOC 页数:7 大小:326.50KB
返回 下载 相关 举报
考试必考mapobjects特征查找_第1页
第1页 / 共7页
考试必考mapobjects特征查找_第2页
第2页 / 共7页
考试必考mapobjects特征查找_第3页
第3页 / 共7页
考试必考mapobjects特征查找_第4页
第4页 / 共7页
考试必考mapobjects特征查找_第5页
第5页 / 共7页
点击查看更多>>
资源描述

《考试必考mapobjects特征查找》由会员分享,可在线阅读,更多相关《考试必考mapobjects特征查找(7页珍藏版)》请在金锄头文库上搜索。

1、MapObject特征查询特征查询二、实验内容、步骤和结果二、实验内容、步骤和结果(要求:详细写清楚本次实验的完成的主要内容主要内容、具体实施步骤具体实施步骤和实验结果实验结果。纸张不够可以自行添 加。 )一、打开一个 VB 标准工程,该工程包含两个窗体 Form1 和 Form2。分别对两个窗体进行界面设计。具体的设计步骤如下所示:(1)在工程中添加部件:ESRI MapObjects 2.2,Microsoft FlexGrid control 6.0 (2)在 Form1 中添加一个 Map 控件和一个 command 控件,在 Map 中添加相应的数据,以便运行时使用。设计完的 For

2、m1 如下图所示:(3)Form2 是该实验中界面设计的主要部分,其设计界面如下图所示:二、编写相应的代码(1)在 Form1 的代码窗口中编写如下代码,实现单击查询按钮后显示查询窗体的界面。Private Sub Command1_Click()Form2.ShowEnd Sub运行程序前先在 Map1 中添加图形文件【整的思路:窗体加载时,在 combo1 中则显示地图的所有图层(该地图为多图层地图) ,点击 combo1 则会在 list1 中出现对应选择图层图层的属性名,点击 list1 则会在 list2 中显示出与 list1 先对应属性的属性值。 】(2)在 Combo1 中添加

3、图层,在窗体加载时,就在 Combo1 中显示图层名。Private Sub Form_Load()Call loadlys 定义一个加载子过程 End SubPrivate Sub loadlyrs() 申明子过程Combo1.Clear 清空For Each lyr In Form1.Map1.Layers lyr 为图层If lyr.LayerType = moMapLayer ThenCombo1.AddItem lyr.NameEnd IfNext lyrCombo1.ListIndex = 0End Sub (3)点击 combo1 设置 combo1 中选中的图层,并将该图层的(

4、记录集:records)属性名加载到list1 中。Private Sub Combo1_click()List1.ClearSet lyr = Form1.Map1.Layers(Combo1.ListIndex) lyr 为当前 combo1 中选中的图层Set pRect = lyr.RecordsSet tDesc = pRect.TableDescFor i = 0 To tDesc.FieldCount 1 将 combo1 中选中图层的属性名依次加入到 list1 中List1.AddItem tDesc.FieldName(i) Next iEnd SubB、单击字段名列表中的

5、字段在字段值列表中显示相应的字段值Private Sub List1_Click()List2.ClearSet pRect = lyr.RecordspRect.MoveFirstDim strField As StringstrField = List1.List(List1.ListIndex) While Not pRect.EOFList2.AddItem pRect.Fields(strField).ValueAsStringpRect.MoveNextWendEnd Sub该步骤运行结果如图所示:(4)双击列表框(list)中的字段名、字段值;单击按钮构建查询语句,并使查询的 S

6、QL 语句在文本框(textbox)中显示:首先输入 list1 中的属性名Private Sub List1_DblClick() 双击Dim tempstring As Stringtempstring = Right(Text1.Text, 3)If tempstring = “And“ Or tempstring = “or“ Or tempstring = “!“ ThenText1.Text = Text1.Text & “ “ & List1ElseText1.Text = Text1.Text & List1End IfEnd Sub然后选择 list2 中对应的属性值,此时要

7、进行判断,要不构建的 where 语句将出错Private Sub List2_DblClick()Dim strSQL As StringIf pRect.Fields(List1.List(List1.ListIndex).Type = moString Then 使用 type 判断其属性值类型Text1.Text = Text1.Text & “ & List2 & “ElseText1.Text = Text1.Text & List2End IfEnd Sub该部分运行结果如图所示:(5)点击“查询”按钮,在MSHFlexGrid1中显示相应的属性表 “太难可省 Private S

8、ub Command2_Click(Index As Integer)Set g_sRecordset = lyr.SearchExpression(Text1.Text)With MSFlexGrid1.Cols = tDesc.FieldCount测试:人工统计方法g_sRecordset.MoveFirstWhile Not g_sRecordset.EOFpCount = pCount + 1g_sRecordset.MoveNextWend.Rows = pCount + 1.AllowUserResizing = flexResizeColumns.ClearEnd WithFor

9、 i = 0 To tDesc.FieldCount - 1MSFlexGrid1.TextMatrix(0, i) = tDesc.FieldName(i)Next ir控制行,c控制列Dim r As IntegerDim c As Integerg_sRecordset.MoveFirstFor r = 1 To pCountFor c = 0 To tDesc.FieldCount - 1MSFlexGrid1.TextMatrix(r, c) = g_sRecordset.Fields(tDesc.FieldName(c).ValueNext cg_sRecordset.MoveNe

10、xtNext r End Sub 运行结果如下所示:(6)双击属性值,居中显示图形: Private Sub MSFlexGrid1_dblClick()g_sRecordset.MoveFirstFor i = 0 To pCount - 1g_sRecordset.MoveNextNext iDim theshape As ObjectDim shapeX As DoubleDim shapeY As DoubleDim rect As Rectangleg_sRecordset.MoveFirstSet theshape = g_sRecordset(“shape“).ValueIf g

11、_sRecordset(“shape“).Type = moPoint ThenshapeX = g_sRecordset(“shape“).Value.XshapeY = g_sRecordset(“shape“).Value.YForm1.Map1.CenterAt shapeX, shapeYElseSet rect = g_sRecordset(“shape“).Value.Extentrect.ScaleRectangle 1.2Form1.Map1.Extent = rectEnd If End Sub(7)编写闪烁、清除、取消三个按钮的代码,并运行程序:清除 SQL 构造框 Pr

12、ivate Sub Command3_Click() Text1.Text = “ MSFlexGrid1.Clear End Sub闪烁 Private Sub Command4_Click() Dim shp as mapobject2.polygon Set g_sRecordset = lyr.SearchExpression(Text1.Text) Set shp = g_sRecordset.fields(“shape”).value 将查找到的记录集转换为图形Form1.Map1.FlashShape shp,2 End Sub 取消 Private Sub Command5_Click()Set lyr = NothingEnd End Sub

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 中学教育 > 初中教育

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号