码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2018-06-06 12:26:40      阅读:428      评论:0      收藏:0      [点我收藏+]

标签:new   sse   pen   ltm   根据   AC   break   lines   next   

两种方式:
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发布的地图服务

标签:new   sse   pen   ltm   根据   AC   break   lines   next   

原文地址:https://www.cnblogs.com/huangyanjia/p/9144077.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!