zoukankan      html  css  js  c++  java
  • 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;
            }
  • 相关阅读:
    Linux:DHCP服务配置
    调整 全局jvm 大小 tomcat 调整jvm大小
    Arts打卡第8周
    mysql 对返回的值是null进行判断和重新赋值
    从xml中返回的对象,和new 返回的对象时不同的。
    检查时异常和运行是异常 + 事务回滚 +隔离级别
    怎么在for循环中新建出不同的list
    mysql中查询某个字段重复的数据
    Arts打卡第7周
    将Excel文件导入到Navicat Premium中日期变为0000-00-00
  • 原文地址:https://www.cnblogs.com/tianciliangen/p/5435665.html
Copyright © 2011-2022 走看看