现在的位置: 首页 > 综合 > 正文

Arcengine连接Map service

2012年09月07日 ⁄ 综合 ⁄ 共 1187字 ⁄ 字号 评论关闭
            IAGSServerConnectionFactory connectionFactory = new AGSServerConnectionFactory();
            IPropertySet propertySet = new PropertySet();
            IAGSServerConnection connection;
            propertySet.SetProperty("url", "http://meng/arcgis/services");
            connection = connectionFactory.Open(propertySet, 0);
            // Get "MapService" MapServer object

            IAGSEnumServerObjectName serverObjectNames;
            IAGSServerObjectName serverObjectName;
            serverObjectNames = connection.ServerObjectNames;
            while ((serverObjectName = serverObjectNames.Next()) != null)
            {

                if (serverObjectName.Name.Equals("zhyxk") && serverObjectName.Type.Equals("MapServer"))
                    break;

            }

            if (serverObjectName == null)
                return;
            IName name = serverObjectName as IName;
            IMapServer mapServer = name.Open() as IMapServer;

            // Create MapServerLayer using AGS data source
            ESRI.ArcGIS.Carto.IMapServerLayer layer = new MapServerLayer() as IMapServerLayer;
            layer.ServerConnect(serverObjectName, mapServer.DefaultMapName);

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

抱歉!评论已关闭.