mapx下完成的多项实例程序.doc

上传人:枫** 文档编号:558446273 上传时间:2023-11-20 格式:DOC 页数:9 大小:36.01KB
返回 下载 相关 举报
mapx下完成的多项实例程序.doc_第1页
第1页 / 共9页
mapx下完成的多项实例程序.doc_第2页
第2页 / 共9页
mapx下完成的多项实例程序.doc_第3页
第3页 / 共9页
mapx下完成的多项实例程序.doc_第4页
第4页 / 共9页
mapx下完成的多项实例程序.doc_第5页
第5页 / 共9页
点击查看更多>>
资源描述

《mapx下完成的多项实例程序.doc》由会员分享,可在线阅读,更多相关《mapx下完成的多项实例程序.doc(9页珍藏版)》请在金锄头文库上搜索。

1、mapx下完成的多项实例程序如何在MapX下读取属性值 有三种方法:1 由Layer对象的KeyField属性来设立要读取属性值的字段名。接着,由Feature对象的keyValue读取此行的属性值。2 将图层加入到Datasets, 由Dataset对象的Value(x,y)属性,通过设置行号,列号来获得属性值。3 将图层加入到Datasets,之后由RowValues(ftr)获取整行的值。Dim ds As MapXLib.Dataset, lyr As MapXLib.layerDim ftrs As FeaturesDim ftr As FeatureDim rv As RowVal

2、ueDim rvs As RowValuesDim DsName As String 数据集名Dim DsRows As Long, DsCols As LongDim i As Long, j As LongSet ds = Formmain.Map1.Datasets.Item(DsName)Set lyr = ds.layerSet ftrs = lyr.AllFeaturesDsCols = ds.Fields.CountDsCols = DsCols + 1 DsRows = ftrs.CountGrid1.Rows = DsRows + 1Grid1.Cols = DsColsGr

3、id1.Row = 0For i = 0 To DsCols - 1Grid1.Col = iGrid1.Text = ds.Fields.Item(i + 1).NameNext iGrid1.Col = DsCols - 1Grid1.Text = Fkeylyr.BeginAccess miAccessReadi = 1For Each ftr In ftrsSet rvs = ds.RowValues(ftr)j = 0For Each rv In rvsIf Not IsNull(rv.Value) Then Grid1.TextArray(i * DsCols + j) = Tri

4、m(rv.Value)j = j + 1NextGrid1.TextArray(i * DsCols + j) = ftr.FeatureKeyi = i + 1Nextlyr.EndAccess miAccessEndSet ftr = NothingSet ftrs = NothingSet ds = NothingSet rv = NothingSet rvs = NothingSet lyr = Nothing注意:BeginAccess,以及EndAccess可以明显的提高属性读取的速度。回页首自定义范围专题图mapx 的专题图用户可以进行完全的定制,下面是自定义范围专题图的例子。D

5、im ds As New MapXLib.DatasetDim thm As New MapXLib.ThemeSet ds = Formmain.Map1.Datasets(ToolBars.Combo2.Text)Set thm = ds.Themes.add(0, aa, aa, False)thm.Legend.Compact = Falsethm.AutoRecompute = Falsethm.ComputeTheme = Falsethm.DataMax = 700thm.DataMin = 100thm.ThemeProperties.AllowEmptyRanges = Tr

6、uethm.ThemeProperties.NumRanges = 7thm.ThemeProperties.DistMethod = miCustomRangesthm.ThemeProperties.RangeCategories(1).Max = 150thm.ThemeProperties.RangeCategories(1).Min = 50thm.ThemeProperties.RangeCategories(2).Max = 250thm.ThemeProperties.RangeCategories(2).Min = 150thm.ThemeProperties.RangeCa

7、tegories(3).Max = 350thm.ThemeProperties.RangeCategories(3).Min = 250thm.ThemeProperties.RangeCategories(4).Max = 450thm.ThemeProperties.RangeCategories(4).Min = 350thm.ThemeProperties.RangeCategories(5).Max = 550thm.ThemeProperties.RangeCategories(5).Min = 450thm.ThemeProperties.RangeCategories(6).

8、Max = 650thm.ThemeProperties.RangeCategories(6).Min = 550thm.ThemeProperties.RangeCategories(7).Max = 750thm.ThemeProperties.RangeCategories(7).Min = 650thm.ComputeTheme = Truethm.AutoRecompute = Truethm.Visible = True 回页首在mapx中查找对象的方法两种方式:1 使用Find对象的Search方法。在mapx3.5中只能作到完全匹配查找,在MapX4.0中SearchEx方法则

9、可以找到多个匹配的记录,其结果由 FindResult.Matches获取。详细请参看有关Find.SearchEx 方法的文档以及示例。2 使用Layer 对象的OBJECT.Search (strWhere)方法。其参数为SQL查询的WHERE子句。例如:Set ftrs = lyr.Search(Character_Name = 北京市) ;Set ftrs = lyrUSA.Search(TOTPOP 1000000)注意:1。字符串外加两个双引号。2。首先将图层加入数据集Datasets 才能使用查询。模糊查询最方便的方法是使用第二种方法例如Set ftrs = lyr.Search

10、(Character_Name like %市) ;模糊查询 回页首在mapx中如何紧缩表在Mapx4.51下可以使用LayerInfo 的创建带结构的临时表和新表的功能来完成紧缩:Set lyr = Formmain.Map1.Layers(ToolBbo1.Text)Set ds = Formmain.Map1.Datasets.add(6, lyr) 获取被紧缩表的路径及表名filespec = Formmain.Map1.Layers.Item(ToolBbo1.Text).filespeclayername = lyr.Name 将表临时存放于内存 LayerInfo.Type =

11、6 miLayerInfoTypeTempLayerInfo.AddParameter TableStorageType, MemTable 临时文件保存在磁盘上还是内存。LayerInfo.AddParameter Name, lyrpackLayerInfo.AddParameter Fields, ds.FieldsLayerInfo.AddParameter Features, lyr.AllFeaturesFormmain.Map1.Layers.add LayerInfo, LayerPos Set LayerInfo = Nothing 从地图窗口删除原表Formmain.Map

12、1.Datasets.Remove (ds.Name)Formmain.Map1.Layers.Remove (lyr.Name)Formmain.Map1.RefreshSet lyr = NothingSet ds = Nothing Set lyr = Formmain.Map1.Layers(lyrpack)Set ds = Formmain.Map1.Datasets.add(6, lyr)从磁盘删除原表Kill filespec 回页首在mapx中如何使用自定义栅格符号使用自定义符号首先需要设定style.SymbolType 为miSymbolTypeBitmap,然后指定Sym

13、bolBitmapName 为栅格图像名即可。下面的代码演示了如何在delphi中使用自定义的栅格符号首先调用自定义工具画点procedure TForm1.new1Click(Sender: TObject);beginmap1.ControlInterface.CurrentTool :=111;end;在tooluses事件中如下:procedure TForm1.Map1ToolUsed(Sender: TObject; ToolNum: Smallint; X1, Y1,X2, Y2, Distance: Double; Shift, Ctrl: WordBool;var Enabl

14、eDefault: WordBool);varssymbol :cmapxstyle;p: CMapXPoint;f: cmapxfeature;beginssymbol:=costyle.create;ssymbol.SymbolType :=1;ssymbol.SymbolBitmapSize:=25;请注意将test.bmp文件考到mapx “共有文件路径”+“CUSTSYMB”路径下,例如C:Program FilesCommon FilesMapInfo SharedMapX Common 是 MapX 共有文件的缺省安装路径ssymbol.SymbolBitmapName:=tes

15、t.BMP;p := CoPoint.Create;f :=cofeature.Create ;p.Set_(x1,y1);if toolnum=111 then beginf:=map1.ControlInterface.FeatureFactory.CreateSymbol(p,ssymbol);map1.ControlInterface.Layers.Item(1).AddFeature(f,EmptyParam);end;回页首 在mapx中如何使用自定义鼠标在mapx4.0,及以上版本中允许用户自定义鼠标。程序如下:Map1.MousePointer = miCustomCursorMap1.MouseIcon = c:windowscursorsglobe.ani mapx 中还对鼠标滚动轮提供支持,属性如下Map

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 生活休闲 > 科普知识

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