返回首页
当前位置: 主页 > GPS学院 > 应用软件 >

用MapX快速开发(4)

时间:2008-01-18 10:58来源:GPS之家-导航之家 作者:www.gpsuu.com
五、输出 1、属性的输出 输出到EXCEL表: For I=1 to Flds.Count Lyr.KeyFields=Flds.Item(i).Name Excel(1,I).Cell=Ftr.KeyValue Next 2、复制、粘贴 Global CopyFtrs AS MapXlib.Features Set lyr=mainmap.Layers

五、输出

1、属性的输出   输出到EXCEL表:
For I=1 to Flds.Count
Lyr.KeyFields=Flds.Item(i).Name
Excel(1,I).Cell=Ftr.KeyValue
Next
2、复制、粘贴
Global CopyFtrs AS MapXlib.Features

Set lyr=mainmap.Layers.item(LayerName)
Set Ftrs=Lyr.Selection.Clone      ‘复制选中集合
‘复制
For I=1 to Ftrs.Count
CopyFtrs.add Ftrs.Item(I)
Next

‘粘贴(图形)
Set lyr_1=mainmap.Layers.item(LayerName_1)
Mainmap.AutoRedraw=False
Lyr_1.Editabled=True
For J=1 to CopyFtrs.Count
   Lyr_1.AddFeature CopyFtrs.Item(J)
Next
Lyr_1.Refresh
Mainmap.AutoRedraw=True
Lyr_1.Editabled=False

 

 

 

 

 

六、专题图

 

 

 

 

 

 

 

 

 

 

 

      LayerInfo.Type = miLayerInfoTypeNewTable
      LayerInfo.AddParameter FileSpec, FilePath + LayerName + .TAB
      LayerInfo.AddParameter NAME, LayerName
      LayerInfo.AddParameter Features, LyrTemp.AllFeatures
      LayerInfo.AddParameter Fields, Flds
        
      LayerInfo.AddParameter AutoCreateDataset, 1
      LayerInfo.AddParameter datasetname, LayerName
      Set Lyr = MainMap.Layers.Add(LayerInfo, 1)
      
      ´删除临时表
      MapTemp.Layers.Remove (MapTemp.Layers.Count)
      MapTemp.Refresh
   Next
      
   Set Lyr = Nothing
   Set Ds = Nothing
   Set Flds = Nothing
   Set LayerInfo = Nothing

 

八、如何和大型数据库关联

 

 

 

 

 

 

 

 

十一、构造一个GIS应用系统

 

 

 

 

 

(2)系统是否稳定(界面要求):A、字段全部用英文,B、地图拓扑关系在进入系统以前进行必要的验证,C、文件地图数据中字段数减少到最小,可使访问属性频率大大减少,可有效保证其他用户访问时不会大量出现访问拒绝的现象;D、数据提交时尽可能采用事务机制:事务开始:  Lyr.BeginAccess,事务结束:Lyr.EndAccess;E、数据修改提交时尽可能采用批量提交。至于界面要求,应主要满足从地图对象获取相关的要求。

 

 3、地图的打印
  Dim iScaleMode As Integer
  iScaleMode = MainMap.Container.ScaleMode
  MainMap.Container.ScaleMode = 6
On Error GoTo PrinterError
  
  Printer.Print
  Printer.CurrentX = 0
  Printer.CurrentY = 0
  MainMap.PrintMap Printer.hDC, 0, 0, MainMap.Width * 100, MainMap.Height * 10
0
  Printer.NewPage
  Printer.EndDoc
  MainMap.Container.ScaleMode = iScaleMode
  Exit Sub
  
PrinterError:
  If Err.Number = 482 Then
     On Error Resume Next
     CommonDialog1.Flags = &H40
     CommonDialog1.ShowPrinter
  Else
     MsgBox     打印机存在错误,请更正后重试。错误号: + (Str(Err.Number)),
, 失败
  End If
  
4、另存为图片文件
MainMap.ExportMap(App.Path+”Images”, miFormatJPEG)   ‘输出当前地图窗口
参数设置:MainMap.ExportSelection=True   ‘将选中部分以不同于其他未选中地图部分
形式输出
  6种专题图:除独立值专题图绑定的字段类型可以是字符的以外,都必须是数字类型。与其
他数据源绑定时,使用ODBC
调用ThemeDlg对话框可以让用户自己定义专题图。示例:
For Each ftr In lyr.Selection
 ' The children of the layer are the individual
 ' features
Set ftrNode = QueryTree.Nodes.Add(lyrNode, tvwChild,lyr.Name _ & ftr.Name & Str$(ftr.FeatureID), ftr.Name) For Each fld In ds.Fields ' Each feature has data attached to it; add  this data as a child of the feature lyr.KeyField = fld.Name QueryTree.Nodes.Add ftrNode, tvwChild, , lyr.KeyField _  & : & ftr.KeyValue 七、在MapX下紧缩表  在Professional里面,紧缩表用 Pack Table 语句完成。而在MapX中则需要使用临时图层
,并用复制技术来完成。示例:
‘紧缩当前Map对象中的所有图层
   Dim LayerInfo As New MapXLib.LayerInfo
   Dim Lyr As MapXLib.Layer
   Dim LyrTemp As MapXLib.Layer
   Dim Flds As MapXLib.Fields
   Dim Ds As MapXLib.Dataset
   
   Dim I As Integer
   Dim LayerName, FilePath As String
   
   On Error Resume Next
   
   For I = MainMap.Layers.Count To 1 Step -1
      ´复制源表数据到临时表
      Set Lyr = MainMap.Layers.Item(I)
      Set Ds = Lyr.Datasets.Item(1)
      Set Flds = Ds.Fields
      
      LayerName = Lyr.Name
      
      LayerInfo.Type = miLayerInfoTypeTemp
      LayerInfo.AddParameter FileSpec, LayerName
      LayerInfo.AddParameter NAME, LayerName
     LayerInfo.AddParameter Features, Lyr.AllFeatures‘复制所有有效图元
      LayerInfo.AddParameter Fields, Flds    ’复制字段列表
      
      LayerInfo.AddParameter AutoCreateDataset, 1
      LayerInfo.AddParameter datasetname, LayerName
Set LyrTemp = MapTemp.Layers.Add(LayerInfo, 1)    ‘复制到另外Map对象
      
      ´删除源表
      Set Lyr = Nothing
      FilePath = MainMap.Layers.Item(I).Filespec
      LayerName = Mid(FilePath, InStr(1, FilePath, Maps) + 6, Len(FilePath)
- InStr(1, FilePath, Maps))
      FilePath = Mid(FilePath, 1, InStr(1, FilePath, Maps) + 5)
      LayerName = Mid(LayerName, 1, Len(LayerName) - 4)
      
      MainMap.Layers.Remove (I)
      MainMap.Refresh
      
      Kill FilePath + LayerName + .TAB
      
      ´复制临时表数据到源表
      Set LyrTemp = MapTemp.Layers.Item(LayerName)
  (责任编辑:admin)
[ GPSUU整理发布,版权归原作者所有。]
顶一下
(1)
50%
踩一下
(1)
50%
------分隔线----------------------------

推荐内容