ae显示arcserver的地图服务

acmap可以直接显示arcserver上的地图服务,那ae也应该是可以的。

方法就是创建一个IAGSServerConnection,该接口的ServerObjectNames能获取serverobject的名称,其中就包括Service的名称。可以将IName转换为IMapServer对象,最后创建一个IMapServerLayer来显示。

            IAGSServerConnectionFactory connFac = new AGSServerConnectionFactoryClass();
            IPropertySet propertySet = new PropertySetClass();
            propertySet.SetProperty("machine", serverName);
            //propertySet.SetProperty("url", serverName);
            IAGSServerConnection conn = connFac.Open(propertySet, 0);
            IAGSEnumServerObjectName names = conn.ServerObjectNames;
            IAGSServerObjectName serviceObjName = null;
            IAGSServerObjectName temObjName = null;
            names.Reset();
            while ((temObjName = names.Next()) != null)
            {
                if (temObjName.Name == serviceName)
                { serviceObjName = temObjName; break; }
            }
            IMapServer mapServer = ((IName)serviceObjName).Open() as IMapServer;
            IMapServerLayer layer = new MapServerLayerClass();
            layer.ServerConnect(serviceObjName, mapServer.DefaultMapName);
posted on 2011-09-16 17:06  漫步人生  阅读(1304)  评论(1编辑  收藏  举报