Engine加载ArcGIS Online和ArcGIS Server发布的地图服务

Posted 元宝山小王子

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Engine加载ArcGIS Online和ArcGIS Server发布的地图服务相关的知识,希望对你有一定的参考价值。

两种方式:
1. 可以通过遍历的方式,根据地图服务的名称进行判断,然后加载。

IAGSServerObjectName pSOName = null; 
IAGSServerObjectName psoname = null; 
IAGSServerConnection con = new AGSServerConnection(); 
IAGSServerConnectionFactory2 confactory = new AGSServerConnectionFactory() as IAGSServerConnectionFactory2; 
IPropertySet propertyset = new PropertySet(); 
IMapServerLayer mapserverlayer = new MapServerLayerClass(); 

propertyset.SetProperty(URL, http://192.168.220.116:6080/arcgis/rest/services); 

con = confactory.Open(propertyset, 0); 

IAGSEnumServerObjectName enumSOName = con.ServerObjectNames; 

pSOName = enumSOName.Next(); 
while (pSOName != null) 
{ 
if (pSOName.Name == MyMapService1) 
{ 
psoname = pSOName; 
break; 
} 
pSOName = enumSOName.Next(); 
} 
IName pName = psoname as IName; 
IMapServer mapserver = pName.Open() as IMapServer; 

mapserverlayer.ServerConnect(pSOName, mapserver.DefaultMapName); 
axMapControl1.AddLayer(mapserverlayer as ILayer); 
axMapControl1.Refresh();

2. Engine 10.1及之后版本的话可以使用IMapServerRESTLayer加载,测试代码:

IMapServerRESTLayer mapServerRESTLayer = new MapServerRESTLayerClass();
            mapServerRESTLayer.Connect(http://cache1.arcgisonline.cn/ArcGIS/rest/services/ChinaOnlineStreetPurplishBlue/MapServer);

            axMapControl1.AddLayer(mapServerRESTLayer as ILayer);
            axMapControl1.Refresh();

 

以上是关于Engine加载ArcGIS Online和ArcGIS Server发布的地图服务的主要内容,如果未能解决你的问题,请参考以下文章

ArcGIS Engine开发前基础知识

ArcGIS engine C#开发出现未能加载程序集ESRI.ArcGIS.AxControls

ArcGIS Engine开发之地图基本操作

ArcGIS Engine开发之地图基本操作

ArcGIS Engine -- 常用方法

ArcGIS Engine开发前基础知识