Engine加載ArcGIS Online和ArcGIS Server發佈的地圖服務

兩種方式:
1. 能夠經過遍歷的方式,根據地圖服務的名稱進行判斷,而後加載。api

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();

 地圖服務類型:spa

1.地形圖:http://server.arcgisonline.com/arcgis/rest/services/World_Physical_Map/MapServer?f=jsapirest

2.影像:http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServercode

3.彩色地圖:http://cache1.arcgisonline.cn/ArcGIS/rest/services/ChinaOnlineCommunity/MapServerserver

4.灰色:http://cache1.arcgisonline.cn/ArcGIS/rest/services/ChinaOnlineStreetGray/MapServerblog

5.暖色:http://cache1.arcgisonline.cn/ArcGIS/rest/services/ChinaOnlineStreetWarm/MapServerit

6.午夜藍:http://cache1.arcgisonline.cn/ArcGIS/rest/services/ChinaOnlineStreetPurplishBlue/MapServerio

相關文章
相關標籤/搜索