zoukankan      html  css  js  c++  java
  • maps and layers

    写的不错,看完思路很清晰
    http://hi.baidu.com/murphy1314/blog/category/Arcengine

    【内容】:
    访问Maps和Layers
    遍历maps和layers
    Collections
    Enumerations
    创建一个新的图层
    使用图层对象的属性
    设置一个图层的数据源

    在ArcMap应用中:
    Application代表ArcMap,
    一个Application有MxDocument组成,
    一个MxDocument由多个Map组成,
    一个Map由多个图层Layer组成,
    图层Layer是FeatureLayer的基类。
    现在,我们要了解,一个FeatureLayer和0或者1个FeatureClass相联合。
    Dataset为抽象基类,Table为实例化类,从Dataset派生,FeatureClass是Table的子类。
    多FeatureClass组成FeatureDataset。

    访问maps:
    由MxDocument访问maps
    得到当前的map
    Dim pMxDoc as IMxDocument
    Set pMxDoc=ThisDocument
    dim pMap as IMap
    set pMap=pMxDoc.FocusMap
    得到maps(IMaps)
    是Map的集合
    Dim pAllMaps as IMaps
    Set pAllMaps=pMxDoc.Maps
    一个地图文档可以包含有多个数据框,每个数据框都可以拥有不同的图层和表现。
    FocusMap是指向当前活动的数据框。

    访问Layers:
    有map和MxDocument访问layers
    得到选定的layer(IMxDocument)
    dim pLayer as ILayer
    Set pLayer=pMxDoc.SelectLayer
    得到指定的图层(IMap)
    dim pLayer as ILayer
    Set pMap=pMxDoc.FocusMap
    set pLayer=pMap.Layer(3)
    得到所有图层(IMap)
    一个图层的enumeration
    dim pAllLayers as IEnumLayer
    set pAllLayers=pMap.Layers

    遍历Maps集合:
    集合是按照顺序的.
    通过下标的到引用.第一项的下标为0.
    dim intIndex as Integer
    dim pMaps as IMaps
    set pMaps=pMxDoc.maps

    for intIndex=0 to pMaps.Count-1
        MsgBox pMaps.item(intIndex).Name
    next

    遍历一个Map对象中的图层对象:
    IMaps图层集属性返回IEnumLayers,其只有Next和Reset两个方法.
    好像是具有较少属性和方法的集合.Next返回ILayer,Reset当前指针指向top,即第一项的前边。
    dim pLayer as ILayer
    dim pLayers as IEnumLayers
    set pLayers=pMap.layers

    set pLayer=pLayers.Next;
    set pLayer=pLayers.Next;

    添加一个新图层到Map中:
    Layer是一个抽象类:不能创建
    可创建的子类:TinLayer,FeatureLayer,RasterLayer等。
    dim pFLayer as ILayer
    set pFLayer=new FeatureLayer
    dim pMxDoc as IMxDocument
    dim pMap as IMap
    set pMxDoc=thisdocument
    set pMap=pMxDoc.focusmap
    pMap.AddLayer pFLayer
    因为还没有设置数据源,所以图标为失去数据连接的状态


    使用图层对象:
    ILayer接口的属性:Name Visible ShowTips MaximumScale MinimumScale等
    IGeoDataSet接口属性:Extent SpatialReference

    Dim pLayer as ILayer
    set pLayer=pMxDoc.SelectedLayer

    pLayer.Name="Streets"
    pLayer.Visible=true
    pLayer.ShowTips=false


    设置FeatureLayer的数据源:
    FeatureClass属性(IFeatureLayer)
    指定显示的数据源
    以传引用的方式(必须用set关键字)
    Dim pFLayer as IFeatureLayer
    set pFLayer=new FeatureLayer
    dim pFClass as IFeatureClass
    set pFClass=pSomeObjLayer.FeatureClass
    set pFLayer.FeatureClass=pFClass

  • 相关阅读:
    java高级程序设计(第十周)
    java高级程序设计(第五周)
    java高级程序设计(第四周)
    期末设计(第十四周)
    期末设计(第十三周)
    期末设计(计划进度表)
    Java学习笔记(六)
    Java学习笔记(六)
    Java学习笔记(五)
    Java学习笔记(四)
  • 原文地址:https://www.cnblogs.com/zhangjun1130/p/1406276.html
Copyright © 2011-2022 走看看