html5-img
1 / 35

第六讲 地图组成及图层控制

第六讲 地图组成及图层控制. 2011 年 10 月 17 日 星期一 湖南城市学院(二) 413. 主要内容. 1. Element 对象. 2. MapGrid 对象. 3. MapSurround 对象. 4. Style 对象. 5. 添加、删除图层数据. 6. 图层控制. 一、 Element 对象. 一、 Element 对象. 如何理解 Element 对象 ? 在 Map 对象和 PageLayout 对象显示的数据除了地理数据之外,另一种即为元素数据( Element 对象)。

steffi
Download Presentation

第六讲 地图组成及图层控制

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 第六讲地图组成及图层控制 2011年10月17日星期一 湖南城市学院(二)413

  2. 主要内容 1 Element对象 2 MapGrid对象 3 MapSurround对象 4 Style对象 5 添加、删除图层数据 6 图层控制 市政与测绘工程学院地理信息系统专业

  3. 一、Element对象 市政与测绘工程学院地理信息系统专业

  4. 一、 Element对象 • 如何理解Element对象? • 在Map对象和PageLayout对象显示的数据除了地理数据之外,另一种即为元素数据(Element对象)。 • Graphics Element都是作为图形的形式而存在,在Map视图或者PageLayout视图上是可见的; • Frame Element是作为不可见的容器而存在的。 • Map对象或者PageLayout对象可以通过IElement接口和IGraphicsContainer接口来管理Element对象。 • IGraphicsContainer接口—添加、删除、更新Element; • IElement—确定Element对象的Geometry属性。 市政与测绘工程学院地理信息系统专业

  5. 一、 Element对象-Graphics Element • 1、LineElement • 在Map视图或PageLayout视图中表现为线的形式。 • LineElement实现了ILineElement接口,ILineElement接口只提供了Symbol属性,用于设置线的样式。 市政与测绘工程学院地理信息系统专业

  6. 一、 Element对象-Graphics Element • 2、MarkerElement • 在Map视图或PageLayout视图中表现为点的形式。 • MarkerElement实现了IMarkerElement接口,IMarkerElement接口只提供了Symbol属性,用于设置点的样式。 市政与测绘工程学院地理信息系统专业

  7. 一、 Element对象-Graphics Element • 3、TextElement • 地图标注存在两种形式: • 一种是保存在地理数据库中的标注; • 另一种是使用TextElement。 • TextElement实现了ITextElement接口,ITextElement提供了三个属性: • ScaleText—文字尺寸; • Text—字符; • Symbol—文字符号。 市政与测绘工程学院地理信息系统专业

  8. 一、 Element对象-Graphics Element • 4、GroupElement • GroupElement对象就是将多个Element对象编为一组,作为一个整体使用。 • GroupElement对象实现了IGroupElement接口,该接口定义了6个属性和方法。 市政与测绘工程学院地理信息系统专业

  9. 一、 Element对象-Graphics Element • 4、GroupElement • 例:在PageLayout视图中添加GroupElement IGraphicsContainer pGC = this.axPageLayoutControl1.PageLayout as   IGraphicsContainer;IGroupElement pGroupElement;pGroupElement = this.pJtGrid.JtGrids;if (pGroupElement != null){ pGC.AddElement(pGroupElement as IElement,0);} 市政与测绘工程学院地理信息系统专业

  10. 一、 Element对象-Graphics Element • 5、FillShapeElement • FillShapeElement泛化出了CircleElement、EllipseElement、PolygonElement和RectangleElement等。 • FillShapeElement实现了IFillShapeElement接口,该接口的Symbol属性,可以设置元素的样式。 市政与测绘工程学院地理信息系统专业

  11. 一、 Element对象-Graphics Element • 6、PictureElement 市政与测绘工程学院地理信息系统专业

  12. 一、 Element对象-Graphics Element 市政与测绘工程学院地理信息系统专业

  13. 一、 Element对象-Frame Element • MapFrame和MapSurroundFrame • Frame Element主要有两个对象:MapFrame(地图框架)和MapSurroundFrame(地图修饰框架)。 • MapFrame对象是Map对象的的容器,用于管理Map对象; • MapSurroundFrame用于管理MapSurround(比例尺、比例文本、指北针等)对象。 • MapSurroundFrame对象与MapFrame对象相连,当删除MapFrame时, MapSurroundFrame也将被删除。 市政与测绘工程学院地理信息系统专业

  14. 二、MapGrid对象 • 如何理解MapGrid对象? MapGrid是布局视图中的一系列参考线和参考点,用来帮助地图使用者快速地确定地图要素的位置。 市政与测绘工程学院地理信息系统专业

  15. 二、 MapGrid对象 • 如何理解MapGrid对象? 市政与测绘工程学院地理信息系统专业

  16. 二、 MapGrid对象 • 如何理解MapGrid对象? 不同类型的MapGrid 市政与测绘工程学院地理信息系统专业

  17. 二、 MapGrid对象 • 如何理解MapGrid对象? • MapGrid对象实现了IMapGrid接口。 市政与测绘工程学院地理信息系统专业

  18. 三、MapSurround对象 • 如何理解MapSurround对象? 市政与测绘工程学院地理信息系统专业

  19. 三、 MapSurround对象 • 如何理解MapSurround对象? 市政与测绘工程学院地理信息系统专业

  20. 三、 MapSurround对象-图例对象 • 如何理解图例对象? 市政与测绘工程学院地理信息系统专业

  21. 三、 MapSurround对象-图例对象 • 如何理解图例对象? ILegend接口 市政与测绘工程学院地理信息系统专业

  22. 三、 MapSurround对象-指北针对象 • 如何理解指北针对象? • 指北针对象(MarkerNorthArrow)实现了IMarkerNorthArrow接口。 市政与测绘工程学院地理信息系统专业

  23. 三、 MapSurround对象-比例尺对象 • 如何理解比例尺对象? 市政与测绘工程学院地理信息系统专业

  24. 三、 MapSurround对象-比例尺对象 • 如何理解比例尺对象? 市政与测绘工程学院地理信息系统专业

  25. 三、 MapSurround对象-比例文本对象 • 如何理解比例文本对象? 市政与测绘工程学院地理信息系统专业

  26. 四、Style对象 市政与测绘工程学院地理信息系统专业

  27. 四、 Style对象 市政与测绘工程学院地理信息系统专业

  28. 四、 Style对象 市政与测绘工程学院地理信息系统专业

  29. 五、添加、删除图层 • 如何添加shp图层?         /// <summary>        /// 添加Shape文件/// </summary>        /// <param name="ShapeFilePath">Shape文件所在的目录</param>        /// <param name="ShapeFileName">Shape文件名城,不要后缀,不要目录</param>        public void LoadShapeFile(string ShapeFilePath, string ShapeFileName)        {            Debug.Assert(pMap != null, "Map is null");            IWorkspaceFactory pWorkFactory = new ShapefileWorkspaceFactoryClass();            IPropertySet pSet = new PropertySetClass();            pSet.SetProperty("DATABASE", ShapeFilePath);            IWorkspace pWorkSpace = pWorkFactory.Open(pSet, 0);            IFeatureWorkspace pFeatWorkSpace = pWorkSpace as IFeatureWorkspace;            IFeatureClass pFeatClass = pFeatWorkSpace.OpenFeatureClass(ShapeFileName);             ILayer pLayer = new FeatureLayerClass();            (pLayer as IFeatureLayer).FeatureClass = pFeatClass;            pMap.AddLayer(pLayer);        } 市政与测绘工程学院地理信息系统专业

  30. 五、添加、删除图层 • 如何添加Access数据库数据?         /// <summary>        /// 装载Access数据库数据/// </summary>        /// <param name="AccessFileName">Access数据库文件名称</param>        /// <param name="FeatClassName">需要装载的图层名称</param>        public void LoadAccessLayer(string AccessFileName, string FeatClassName)        {            Debug.Assert(pMap != null, "Map is null");            IWorkspaceFactory pWorkFactory = new AccessWorkspaceFactoryClass();            IPropertySet pSet = new PropertySetClass();            pSet.SetProperty("DATABASE", AccessFileName);            IWorkspace pWorkSpace = pWorkFactory.Open(pSet, 0);            IFeatureWorkspace pFeatWorkSpace = pWorkSpace as IFeatureWorkspace;            IFeatureClass pFeatClass = pFeatWorkSpace.OpenFeatureClass(FeatClassName);             ILayer pLayer = new FeatureLayerClass();            (pLayer as IFeatureLayer).FeatureClass = pFeatClass;            pMap.AddLayer(pLayer);        } 市政与测绘工程学院地理信息系统专业

  31. 五、添加、删除图层 • 如何添加Coverage数据?         /// <summary>        /// 装载Coverage数据/// </summary>        /// <param name="CoverageFilePath">Coverage数据所在的目录名称</param>        /// <param name="FeatClassName">Coverage图层名称,不包含后缀</param>        public void LoadCoverageLayer(string CoverageFilePath, string FeatClassName)        {            Debug.Assert(pMap != null, "Map is null");            IWorkspaceFactory pWorkFactory = new ArcInfoWorkspaceFactoryClass();            IPropertySet pSet = new PropertySetClass();            pSet.SetProperty("DATABASE", CoverageFilePath);            IWorkspace pWorkSpace = pWorkFactory.Open(pSet, 0);            IFeatureWorkspace pFeatWorkSpace = pWorkSpace as IFeatureWorkspace;            IFeatureClass pFeatClass = pFeatWorkSpace.OpenFeatureClass(FeatClassName);             ILayer pLayer = new FeatureLayerClass();            (pLayer as IFeatureLayer).FeatureClass = pFeatClass;            pMap.AddLayer(pLayer);        } 市政与测绘工程学院地理信息系统专业

  32. 五、添加、删除图层 • 如何添加装载图片文件?         /// <summary>        /// 装载图片文件/// </summary>        /// <param name="ImageFilePath">图片所在的目录名称</param>        /// <param name="ImageFileName">图片文件名称</param>        public void LoadImageLayer(string ImageFilePath, string ImageFileName)        {            Debug.Assert(pMap != null, "Map is null");            IWorkspaceFactory pWorkFactory = new RasterWorkspaceFactoryClass();            IPropertySet pSet = new PropertySetClass();            pSet.SetProperty("DATABASE", ImageFilePath);            IRasterWorkspace rasterWorkspace = pWorkFactory.Open(pSet, 0) as IRasterWorkspace;            IRasterDataset rasterDS = rasterWorkspace.OpenRasterDataset(ImageFileName);            ILayer pLayer = new RasterLayerClass();             (pLayer as IRasterLayer).CreateFromDataset(rasterDS);            pMap.AddLayer(pLayer);        } 市政与测绘工程学院地理信息系统专业

  33. 五、添加、删除图层 • 如何装载SDE图层?         /// <summary>        /// 装载SDE图层/// </summary>        /// <param name="ServerName">服务器名称</param>        /// <param name="InstanceName">SDE实例名称</param>        /// <param name="DbName">数据库名称</param>        /// <param name="UserName">用户名称</param>        /// <param name="Password">用户口令</param>        /// <param name="SdeVersion">SDE版本</param>        /// <param name="FeatClassName">需要装载的FeatuerClass的名称</param>        /// <param name="Filter">图层过滤条件</param>        public void LoadSDELayer(string ServerName, string InstanceName, string DbName,                     string UserName, string Password,string SdeVersion,                    string FeatClassName,string Filter)        {            Debug.Assert(pMap != null, "Map is null");            IPropertySet pSet = new PropertySetClass();            pSet.SetProperty("Server", ServerName);            pSet.SetProperty("Instance", InstanceName);            pSet.SetProperty("Database", DbName);            pSet.SetProperty("user", UserName);            pSet.SetProperty("password", Password);            pSet.SetProperty("version", SdeVersion);            LoadSDELayer(pSet, FeatClassName,Filter);        } 市政与测绘工程学院地理信息系统专业

  34. 五、添加、删除图层 • 如何装载SDE图层?         public void LoadSDELayer(IPropertySet pSet, string FeatClassName, string Filter)        {            Debug.Assert(pMap != null, "Map is null");            IWorkspaceFactory pWorkFactory = new SdeWorkspaceFactoryClass();            IWorkspace pWorkSpace = pWorkFactory.Open(pSet, 0);            IFeatureWorkspace pFeatWorkSpace = pWorkSpace as IFeatureWorkspace;            IFeatureClass pFeatClass = pFeatWorkSpace.OpenFeatureClass(FeatClassName);             ILayer pLayer = new FeatureLayerClass();            (pLayer as IFeatureLayer).FeatureClass = pFeatClass;            IFeatureLayerDefinition pLayerDef =pLayer as IFeatureLayerDefinition;            pLayerDef.DefinitionExpression = Filter;            pMap.AddLayer(pLayer);                    } 市政与测绘工程学院地理信息系统专业

  35. 六、图层控制 • 如何理解图层控制? • 地图是由多个图层按一定的顺序叠加起来的,通过索引值或图层名称可获取指定的图层,如: ILayer pLayer=axMapControl1.get_Layer(index) ILayer pLayer=axMapControl1.get_Layer(layername) • 图层移动:IMap接口的MoveLayer方法; • 图层可见性:ILayer接口的Visible属性。 市政与测绘工程学院地理信息系统专业

More Related