• C#中winform下利用ArcEngine调用ArcGIS Server发布的服务 AE 10


    开发环境:vs2010 + AE 10 测试

    public Form1()
            {
                ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.EngineOrDesktop);
                ESRI.ArcGIS.RuntimeManager.BindLicense(ESRI.ArcGIS.ProductCode.Engine);
    
                InitializeComponent();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                //获得服务对象名称[注意地址和名称;test:发布服务的自定义名称]
                IAGSServerObjectName pServerObjectName = GetMapServer("http://172.18.70.254:8081/ArcGIS/services", "test", false);
                IName pName = (IName)pServerObjectName;
                //访问地图服务
                IAGSServerObject pServerObject = (IAGSServerObject)pName.Open();
                IMapServer pMapServer = (IMapServer)pServerObject;
    
                IMapServerLayer pMapServerLayer = new MapServerLayer() as IMapServerLayer;
                //连接地图服务
    
                pMapServerLayer.ServerConnect(pServerObjectName, pMapServer.DefaultMapName);
                //添加数据图层
    
                axMapControl1.AddLayer(pMapServerLayer as ILayer);
    
                axMapControl1.Refresh();
            }
    
            public IAGSServerObjectName GetMapServer(string pHostOrUrl, string pServiceName, bool pIsLAN)
            {
                //设置连接属性
                IPropertySet pPropertySet = new PropertySet();
                if (pIsLAN)
                    pPropertySet.SetProperty("machine", pHostOrUrl);
                else
                    pPropertySet.SetProperty("url", pHostOrUrl);
    
                //打开连接
    
                IAGSServerConnectionFactory pFactory = new AGSServerConnectionFactory();
                //Type factoryType = Type.GetTypeFromProgID(
                //    "esriGISClient.AGSServerConnectionFactory");
                //IAGSServerConnectionFactory agsFactory = (IAGSServerConnectionFactory)
                //    Activator.CreateInstance(factoryType);
                IAGSServerConnection pConnection = pFactory.Open(pPropertySet, 0);
    
                //Get the image server.
                IAGSEnumServerObjectName pServerObjectNames = pConnection.ServerObjectNames;
                pServerObjectNames.Reset();
                IAGSServerObjectName ServerObjectName = pServerObjectNames.Next();
                while (ServerObjectName != null)
                {
                    if ((ServerObjectName.Name.ToLower() == pServiceName.ToLower()) &&
                        (ServerObjectName.Type == "MapServer"))
                    {
    
                        break;
                    }
                    ServerObjectName = pServerObjectNames.Next();
                }
    
                //返回对象
                return ServerObjectName;
            }
  • 相关阅读:
    golang 用tar打包文件或文件夹
    golang 最和谐的子序列
    golang 轮训加密算法
    golang map
    golang 队列
    golang 栈操作
    golang 多维数组
    golang 数组反转
    c# sendmessage control to scroll
    c# 启动的时候向其他程序传值
  • 原文地址:https://www.cnblogs.com/tianciliangen/p/5435665.html
Copyright © 2020-2023  润新知