ArcEngine在地图上加载Server图层数据

简介: 版权声明:欢迎评论和转载,转载请注明来源。 https://blog.csdn.net/zy332719794/article/details/22183775         加载Server图层数据需要指定两个参数,第一是服务的Url地址,第二是服务中的数据对象名称Name。
版权声明:欢迎评论和转载,转载请注明来源。 https://blog.csdn.net/zy332719794/article/details/22183775

        加载Server图层数据需要指定两个参数,第一是服务的Url地址,第二是服务中的数据对象名称Name。也就是说,一个Url服务中包含了若干个数据对象,我们加载时可以通过名称加载的数据对象,当然也可以遍历将其全部加上。


例:加载服务地址"http://services.arcgisonline.com/ArcGIS/services"中的"ESRI_Imagery_World_2D"数据对象(图层)到地图上。

示例代码:

private void GetServerTest()
        {
            //获得服务对象名称
            IAGSServerObjectName serverObjectName =GetMapServer(
                "http://services.arcgisonline.com/ArcGIS/services", "ESRI_Imagery_World_2D", false);
            IName pName = (IName)serverObjectName;
            //访问地图服务
            IAGSServerObject serverObject = (IAGSServerObject)pName.Open();
            IMapServer mapServer = (IMapServer)serverObject;

            IMapServerLayer mapServerLayer = new MapServerLayer() as IMapServerLayer;
            
            //连接地图服务
            mapServerLayer.ServerConnect(serverObjectName, mapServer.DefaultMapName);
            
            //添加数据图层
            _application.MapControl.AddLayer(mapServerLayer as ILayer);
            _application.MapControl.Refresh();
        } 

        public IAGSServerObjectName GetMapServer(string pHostOrUrl, string pServiceName, bool pIsLAN)
        {        
            //设置连接属性
            IPropertySet propertySet = new PropertySetClass();
            if (pIsLAN)
                propertySet.SetProperty("machine", pHostOrUrl);
            else
                propertySet.SetProperty("url", pHostOrUrl);

            //打开连接
            IAGSServerConnectionFactory factory = new AGSServerConnectionFactory();            
            IAGSServerConnection pConnection = factory.Open(propertySet, 0);

            //Get the image server.
            IAGSEnumServerObjectName pServerObjectNames = pConnection.ServerObjectNames;
            pServerObjectNames.Reset();
            IAGSServerObjectName ServerObjectName = pServerObjectNames.Next();
            while (ServerObjectName != null)
            {
                if ((ServerObjectName.Name.ToLower() == pServiceName.ToLower()) 
                    && (ServerObjectName.Type == "MapServer") )
                {                    
                    break;
                }
                ServerObjectName = pServerObjectNames.Next();
            }

            return ServerObjectName;
        }

下面附上一张效果图:


相关文章
|
9月前
|
测试技术
【sgUploadTileImage】自定义组件:浏览器端生成瓦片图,并转换为File文件序列上传瓦片图
【sgUploadTileImage】自定义组件:浏览器端生成瓦片图,并转换为File文件序列上传瓦片图
|
6月前
|
存储 前端开发 定位技术
osgEarth使用笔记4——加载矢量数据
osgEarth使用笔记4——加载矢量数据
267 0
|
前端开发 容器
Bootstrap4(一)重点----网格系统,图像形状,轮播,多媒体对象,滚动监听
Bootstrap 提供了一套响应式、移动设备优先的流式网格系统,随着屏幕或视口(viewport)尺寸的增加,系统会自动分为最多 12 列。
201 0
Bootstrap4(一)重点----网格系统,图像形状,轮播,多媒体对象,滚动监听
|
数据可视化 定位技术
GIS开发:客户端控制的地图样式
GIS开发:客户端控制的地图样式
124 0
openlayer2 二:加载arcgis server图层
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/bitree1/article/details/80755803 1.
1584 0
|
机器学习/深度学习 定位技术
unity2018使用tileMap生成地图 类似泰拉瑞亚创建和销毁地图块
using System.Collections; using System.Collections.Generic;using UnityEngine;using UnityEngine.Tilemaps; public class CreateTileMap : MonoBehaviour {...
3001 0
openlayers加载动态ArcGIS服务
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/gisdoer/article/details/82853801 openlaye...
1983 0
openlayers5之聚合分析图层Cluster
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/gisdoer/article/details/81805524 openlayer...
1739 0
openlayer2 三:加载geoserver图层
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/bitree1/article/details/80755886 1.
1428 0

热门文章

最新文章