protected override void OnClick()
        {
            IMxDocument mxDoc = (IMxDocument)ArcMap.Application.Document;
            IWMSGroupLayer wmsMapLayer = new WMSMapLayerClass();
            IWMSConnectionName connName = new WMSConnectionNameClass();

            IPropertySet propSet = new PropertySetClass();
            propSet.SetProperty("URL", "https://sampleserver1.arcgisonline.com/ArcGIS/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/WMSServer");
            connName.ConnectionProperties = propSet;

            //Put the WMS service layers in a DataLayer
            IDataLayer dataLayer = (IDataLayer)wmsMapLayer;
            dataLayer.Connect((IName)connName);

            // Get access to WMS service and layer propeties
            IWMSServiceDescription serviceDesc = wmsMapLayer.WMSServiceDescription;
            IWMSLayerDescription groupDesc = serviceDesc.LayerDescription[0];

            //Clear existing WMS service group layer.
            wmsMapLayer.Clear();

            //Create an empty layer and populate it with the desired sub layer index.
            ILayer newLayer;
            IWMSLayer newWMSLayer = wmsMapLayer.CreateWMSLayer(groupDesc.LayerDescription[1]);
            newLayer = (ILayer)newWMSLayer;
            wmsMapLayer.InsertLayer(newLayer, 0);

            //Add the layer to the map.
            mxDoc.FocusMap.AddLayer((ILayer)wmsMapLayer);
            IActiveView activeView = (IActiveView)mxDoc.FocusMap;
            activeView.Refresh();

            ArcMap.Application.CurrentTool = null;
        }
Example #2
0
        public static void AddIdahoWms(string idahoId, string groupLayerName, string token)
        {
            IGroupLayer groupLayer = new GroupLayerClass();

            groupLayer.Name = groupLayerName;

            var wmsMapLayer = new WMSMapLayerClass();

            // create and configure wms connection name, this is used to store the connection properties
            IWMSConnectionName pConnName = new WMSConnectionNameClass();
            IPropertySet       propSet   = new PropertySetClass();

            // create the idaho wms url
            var idahoUrl = string.Format(
                "http://idaho.geobigdata.io/v1/wms/idaho-images/{0}/{1}/mapserv?",
                idahoId, token);

            // setup the arcmap connection properties
            propSet.SetProperty("URL", idahoUrl);
            pConnName.ConnectionProperties = propSet;

            //uses the name information to connect to the service
            IDataLayer dataLayer = wmsMapLayer;

            try
            {
                dataLayer.Connect((IName)pConnName);
            }
            catch (Exception e)
            {
                Jarvis.Logger.Error("Problems connecting to WMS: " + e.Message);
            }

            // get wms service description
            var serviceDesc = wmsMapLayer.IWMSGroupLayer_WMSServiceDescription;

            ILayer wmsLayer = null;

            // add layers for the wms currently there will only be one.
            for (var i = 0; i <= serviceDesc.LayerDescriptionCount - 1; i++)
            {
                var layerDesc = serviceDesc.LayerDescription[i];

                var grpLayer = wmsMapLayer.CreateWMSGroupLayers(layerDesc);
                for (var j = 0; j <= grpLayer.Count - 1; j++)
                {
                    wmsLayer         = wmsMapLayer;
                    wmsMapLayer.Name = idahoId;
                }
            }

            // turn on sub layers, add it to arcmap and move it to top of TOC
//            SublayerVisibleOn(wmsLayer);
            groupLayer.Add(wmsLayer);

            // turn on sub layers, add it to arcmap and move it to top of TOC
            ArcMap.Document.AddLayer(groupLayer);
            ArcMap.Document.FocusMap.MoveLayer(groupLayer, 0);
        }
        public static void AddIdahoWms(string idahoId, string groupLayerName, string token)
        {
            IGroupLayer groupLayer = new GroupLayerClass();
            groupLayer.Name = groupLayerName;

            var wmsMapLayer = new WMSMapLayerClass();

            // create and configure wms connection name, this is used to store the connection properties
            IWMSConnectionName pConnName = new WMSConnectionNameClass();
            IPropertySet propSet = new PropertySetClass();

            // create the idaho wms url
            var idahoUrl = string.Format(
                "http://idaho.geobigdata.io/v1/wms/idaho-images/{0}/{1}/mapserv?",
                idahoId, token);

            // setup the arcmap connection properties
            propSet.SetProperty("URL", idahoUrl);
            pConnName.ConnectionProperties = propSet;

            //uses the name information to connect to the service
            IDataLayer dataLayer = wmsMapLayer;
            try
            {
                dataLayer.Connect((IName)pConnName);
            }
            catch (Exception e)
            {
                Jarvis.Logger.Error("Problems connecting to WMS: " + e.Message);
            }

            // get wms service description
            var serviceDesc = wmsMapLayer.IWMSGroupLayer_WMSServiceDescription;

            ILayer wmsLayer = null;

            // add layers for the wms currently there will only be one.
            for (var i = 0; i <= serviceDesc.LayerDescriptionCount - 1; i++)
            {
                var layerDesc = serviceDesc.LayerDescription[i];

                var grpLayer = wmsMapLayer.CreateWMSGroupLayers(layerDesc);
                for (var j = 0; j <= grpLayer.Count - 1; j++)
                {
                    wmsLayer = wmsMapLayer;
                    wmsMapLayer.Name = idahoId;
                }
            }

            // turn on sub layers, add it to arcmap and move it to top of TOC
            //            SublayerVisibleOn(wmsLayer);
            groupLayer.Add(wmsLayer);

            // turn on sub layers, add it to arcmap and move it to top of TOC
            ArcMap.Document.AddLayer(groupLayer);
            ArcMap.Document.FocusMap.MoveLayer(groupLayer, 0);
        }
Example #4
0
        /// <summary>
        /// 连接到WMS服务器,载入WMS图层
        /// </summary>
        /// <param name="axMapControl1">axMapControl控件</param>
        /// <param name="url">WMS服务器地址</param>
        public static void Connect2WMS(AxMapControl axMapControl1, string url)
        {
            #region 初始化环境
            IPropertySet pPropertyset = new PropertySetClass();
            pPropertyset.SetProperty("url", url);
            IWMSConnectionName pWMSConnectionName = new WMSConnectionNameClass();
            pWMSConnectionName.ConnectionProperties = pPropertyset;
            ILayerFactory pLayerFactory = new EngineWMSMapLayerFactoryClass();//Provides access to members that control the creation of layers through a factory.

            IWMSGroupLayer pWmsMapLayer = new WMSMapLayerClass();
            IDataLayer pDataLayer = pWmsMapLayer as IDataLayer;
            pDataLayer.Connect(pWMSConnectionName as IName);
            IWMSServiceDescription pWmsServiceDesc = pWmsMapLayer.WMSServiceDescription;
            #endregion

            #region 获取WMS图层
            for (int i = 0; i < pWmsServiceDesc.LayerDescriptionCount; i++)
            {
                IWMSLayerDescription pWmsLayerDesc = pWmsServiceDesc.get_LayerDescription(i);
                ILayer pNewLayer = null;

                if (pWmsLayerDesc.LayerDescriptionCount == 0)
                {
                    IWMSLayer pWmsLayer = pWmsMapLayer.CreateWMSLayer(pWmsLayerDesc);
                    pNewLayer = pWmsLayer as ILayer;
                }
                else
                {
                    IWMSGroupLayer pWmsGroupLayer = pWmsMapLayer.CreateWMSGroupLayers(pWmsLayerDesc);
                    for (int j = 0; j < pWmsGroupLayer.Count; j++)
                    {
                        ILayer layer = pWmsGroupLayer.get_Layer(j);
                        if (layer.Name != "admin")
                        {
                            pWmsMapLayer.InsertLayer(layer, 0);
                            layer.Visible = true;
                        }
                    }
                }
            }
            #endregion

            #region 收尾工作
            ILayer pLayer = pWmsMapLayer as ILayer;
            pLayer.Name = pWmsServiceDesc.WMSTitle;
            pLayer.Visible = true;
            axMapControl1.AddLayer(pLayer, 0);

            IEnvelope pEnv = axMapControl1.FullExtent;
            pEnv.Expand(0.8, 0.8, true);
            axMapControl1.Extent = pEnv;
            #endregion
        }
Example #5
0
        public ILayer GetWmsMapServerLyr(string url, string serviceName)
        {
            IPropertySet pPropertyset = new PropertySetClass();

            pPropertyset.SetProperty("url", url);

            IWMSConnectionName pWmsConnectionName = new WMSConnectionNameClass();

            pWmsConnectionName.ConnectionProperties = pPropertyset;
            IWMSConnectionFactory wmsConnFac = new WMSConnectionFactoryClass();
            IName nn = wmsConnFac.Open(pPropertyset, 0, null) as IName;

            IWMSGroupLayer pWmsMapLayer = new WMSMapLayerClass();
            IDataLayer     pDataLayer   = pWmsMapLayer as IDataLayer;

            pDataLayer.Connect(pWmsConnectionName as IName);

            IWMSServiceDescription pWmsServiceDesc = pWmsMapLayer.WMSServiceDescription;

            for (int i = 0; i < pWmsServiceDesc.LayerDescriptionCount; i++)
            {
                IWMSLayerDescription pWmsLayerDesc = pWmsServiceDesc.get_LayerDescription(i);
                ILayer pNewLayer = null;
                if (pWmsLayerDesc.LayerDescriptionCount == 0)
                {
                    IWMSLayer pWmsLayer = pWmsMapLayer.CreateWMSLayer(pWmsLayerDesc);
                    pNewLayer = pWmsLayer as ILayer;
                }
                else
                {
                    IWMSGroupLayer pWmsGroupLayer = pWmsMapLayer.CreateWMSGroupLayers(pWmsLayerDesc);
                    for (int j = 0; j < pWmsGroupLayer.Count; j++)
                    {
                        ILayer layer = pWmsGroupLayer.get_Layer(j);
                        if (layer.Name.ToLower() == serviceName.ToLower())
                        {
                            pWmsMapLayer.InsertLayer(layer, 0);
                            layer.Visible = true;
                            break;
                        }
                    }
                }
            }
            ILayer pLayer = pWmsMapLayer as ILayer;

            pLayer.Name    = pWmsServiceDesc.WMSTitle;
            pLayer.Visible = true;
            return(pLayer);
        }
        private static WMSMapLayerClass CreateWmsMapLayer(string id, int attempt = 0)
        {
            var wmsMapLayer = new WMSMapLayerClass();

            // create and configure wms connection name, this is used to store the connection properties
            IWMSConnectionName pConnName = new WMSConnectionNameClass();
            IPropertySet       propSet   = new PropertySetClass();

            // create the idaho wms url
            var idahoUrl = string.Format(
                "http://idaho.geobigdata.io/v1/wms/idaho-images/{0}/{1}/mapserv?",
                id,
                token);

            Jarvis.Logger.Info("Adding WMS Layer to: " + idahoUrl);

            // setup the arcmap connection properties
            propSet.SetProperty("URL", idahoUrl);
            propSet.SetProperty("VERSION", "1.3.0");
            pConnName.ConnectionProperties = propSet;

            //uses the name information to connect to the service
            IDataLayer dataLayer = wmsMapLayer;

            try
            {
                dataLayer.Connect((IName)pConnName);
            }
            catch (Exception e)
            {
                Jarvis.Logger.Error("Problems connecting to WMS: " + e.Message);

                if (attempt <= 5)
                {
                    Thread.Sleep(500);
                    attempt += 1;
                    return(CreateWmsMapLayer(id, attempt));
                }
                return(null);
            }

            return(wmsMapLayer);
        }
Example #7
0
        /// <summary>
        /// 获取WMS的地图服务图层
        /// </summary>
        /// <param name="serviceUrl">服务地址</param>
        /// <returns></returns>
        public ILayer GetWMSLayer(string serviceUrl)
        {
            IPropertySet propertyset = new PropertySetClass();

            propertyset.SetProperty("url", serviceUrl);

            IWMSConnectionName wmsConnectionName = new WMSConnectionNameClass();

            wmsConnectionName.ConnectionProperties = propertyset;

            IWMSGroupLayer wmsMapLayer = new WMSMapLayerClass();
            IDataLayer     dataLayer   = wmsMapLayer as IDataLayer;

            dataLayer.Connect(wmsConnectionName as IName);
            IWMSServiceDescription wmsServiceDesc = wmsMapLayer.WMSServiceDescription;

            ILayer layer = wmsMapLayer as ILayer;

            layer.Name    = wmsServiceDesc.WMSTitle;
            layer.Visible = true;
            return(layer);
        }
        protected override void OnClick()
        {
            IMxDocument        mxDoc       = (IMxDocument)ArcMap.Application.Document;
            IWMSGroupLayer     wmsMapLayer = new WMSMapLayerClass();
            IWMSConnectionName connName    = new WMSConnectionNameClass();

            IPropertySet propSet = new PropertySetClass();

            propSet.SetProperty("URL", "https://sampleserver1.arcgisonline.com/ArcGIS/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/WMSServer");
            connName.ConnectionProperties = propSet;

            //Put the WMS service layers in a DataLayer
            IDataLayer dataLayer = (IDataLayer)wmsMapLayer;

            dataLayer.Connect((IName)connName);

            // Get access to WMS service and layer propeties
            IWMSServiceDescription serviceDesc = wmsMapLayer.WMSServiceDescription;
            IWMSLayerDescription   groupDesc   = serviceDesc.LayerDescription[0];

            //Clear existing WMS service group layer.
            wmsMapLayer.Clear();

            //Create an empty layer and populate it with the desired sub layer index.
            ILayer    newLayer;
            IWMSLayer newWMSLayer = wmsMapLayer.CreateWMSLayer(groupDesc.LayerDescription[1]);

            newLayer = (ILayer)newWMSLayer;
            wmsMapLayer.InsertLayer(newLayer, 0);

            //Add the layer to the map.
            mxDoc.FocusMap.AddLayer((ILayer)wmsMapLayer);
            IActiveView activeView = (IActiveView)mxDoc.FocusMap;

            activeView.Refresh();

            ArcMap.Application.CurrentTool = null;
        }
Example #9
0
        /// <summary>
        /// Parse WMS Service
        /// </summary>
        /// <param name="urlWMS"></param>
        public void OpenWMS(string urlWMS)
        {
            try
            {
                ///Create an WMSMapLayer Instance - this will be added to the map later
                IWMSGroupLayer pWMSMapLayer = new WMSMapLayerClass() as IWMSGroupLayer;

                ///Create and configure wms connection name, this is used to store the connection properties
                IWMSConnectionName pConnName = new WMSConnectionNameClass();
                IPropertySet       pPropSet  = new PropertySetClass();
                pPropSet.SetProperty("URL", urlWMS);
                pConnName.ConnectionProperties = pPropSet;

                ///Use the name information to connect to the service
                IDataLayer pDataLayer = pWMSMapLayer as IDataLayer;
                IName      pName      = pConnName as IName;
                pDataLayer.Connect(pName);

                ///Get service description, which includes the categories of wms layers
                IWMSServiceDescription pServiceDesc = pWMSMapLayer.WMSServiceDescription;

                ///Configure the layer before adding it to the map
                ILayer pLayer = pWMSMapLayer as ILayer;
                pLayer.Name = pServiceDesc.WMSTitle;
                AddLayer(pLayer);
            }
            catch (System.Runtime.InteropServices.COMException cEx)
            {
                ///Catch comexception handler
                MessageBox.Show("The wms url is invalid!\r\rError message:\r" + cEx.Message);
            }
            catch (Exception ex)
            {
                ///Catch general exception handler
                MessageBox.Show(ex.StackTrace);
            }
        }
        /// <summary>
        ///     Add all current idaho ids for a given catalog id to arcmap
        /// </summary>
        /// <param name="catalogId">catalog id to be added</param>
        /// <param name="colorInterp">Kind of color interpretation.  PAN, MS</param>
        private void AddIdahoWms(string catalogId, string colorInterp)
        {
            HashSet<string> idahoIds;
            switch (colorInterp)
            {
                case "PAN":
                    idahoIds = IdahoIdRepo.GetPanIdahoIds(catalogId);
                    break;
                case "MS":
                    idahoIds = IdahoIdRepo.GetMsIdahoIds(catalogId);
                    break;

                default:
                    idahoIds = null;
                    break;
            }

            if (idahoIds == null) return;

            IGroupLayer groupLayer = new GroupLayerClass();
            groupLayer.Name = colorInterp + " " + catalogId;
            foreach (var id in idahoIds)
            {
                var wmsMapLayer = new WMSMapLayerClass();

                // create and configure wms connection name, this is used to store the connection properties
                IWMSConnectionName pConnName = new WMSConnectionNameClass();
                IPropertySet propSet = new PropertySetClass();

                // create the idaho wms url
                var idahoUrl = string.Format(
                    "http://idaho.geobigdata.io/v1/wms/idaho-images/{0}/{1}/mapserv?",
                    id,
                    this.token);

                Jarvis.Logger.Info("Adding WMS Layer to: " + idahoUrl);

                // setup the arcmap connection properties
                propSet.SetProperty("URL", idahoUrl);
                pConnName.ConnectionProperties = propSet;

                //uses the name information to connect to the service
                IDataLayer dataLayer = wmsMapLayer;
                try
                {
                    dataLayer.Connect((IName)pConnName);
                }
                catch (Exception e)
                {
                    Jarvis.Logger.Error("Problems connecting to WMS: " + e.Message);
                }

                // get wms service description
                var serviceDesc = wmsMapLayer.IWMSGroupLayer_WMSServiceDescription;

                ILayer wmsLayer = null;

                // add layers for the wms currently there will only be one.
                for (var i = 0; i <= serviceDesc.LayerDescriptionCount - 1; i++)
                {
                    var layerDesc = serviceDesc.LayerDescription[i];

                    var grpLayer = wmsMapLayer.CreateWMSGroupLayers(layerDesc);
                    for (var j = 0; j <= grpLayer.Count - 1; j++)
                    {
                        wmsLayer = wmsMapLayer;
                        wmsMapLayer.Name = id;
                    }
                }

                // turn on sub layers, add it to arcmap and move it to top of TOC
                SublayerVisibleOn(wmsLayer);
                groupLayer.Add(wmsLayer);
            }
            // turn on sub layers, add it to arcmap and move it to top of TOC
            ArcMap.Document.AddLayer(groupLayer);
            ArcMap.Document.FocusMap.MoveLayer(groupLayer, 0);
        }
Example #11
0
        public static List<IWMSLayerDescription> listWMSlayers(string WMSurl)
        {
            List<IWMSLayerDescription> lyrNames = new List<IWMSLayerDescription>();

            IPropertySet propSet = new PropertySetClass();
            IWMSConnectionName connName = new WMSConnectionNameClass();
            IWMSGroupLayer wmsMapLayer = new WMSMapLayerClass();
            IDataLayer dataLayer = (IDataLayer)wmsMapLayer;
            IWMSServiceDescription serviceDesc;

            //connect to url
            propSet.SetProperty("URL", WMSurl);
            connName.ConnectionProperties = propSet;
            dataLayer.Connect((IName)connName);
            //get service description
            serviceDesc = wmsMapLayer.WMSServiceDescription;

            lyrNames = listWMSlayers(serviceDesc);
            return lyrNames;
        }
Example #12
0
        public static ILayer getWMSLayerByName(string WMSurl, string layerName)
        {
            IPropertySet propSet = new PropertySetClass();
            IWMSConnectionName connName = new WMSConnectionNameClass();
            IWMSGroupLayer wmsMapLayer = new WMSMapLayerClass();
            IDataLayer dataLayer = (IDataLayer)wmsMapLayer;
            IWMSServiceDescription serviceDesc;
            ILayer qrylyr; ILayer wmsLyr;
            //connect to url
            propSet.SetProperty("URL", WMSurl);
            connName.ConnectionProperties = propSet;
            dataLayer.Connect((IName)connName);
            //get service description
            serviceDesc = wmsMapLayer.WMSServiceDescription;
            //loop through layers

            List<IWMSLayerDescription> lyrs = listWMSlayers(serviceDesc);
            //query layers
            List<IWMSLayerDescription> qry = (
                from IWMSLayerDescription q in lyrs
                where q.Name == layerName select q).ToList<IWMSLayerDescription>() ;

            //nothing found
            if ( qry.Count == 0 ) return null;

            //else
            IWMSLayerDescription layerDesc = qry[0];
            //clear allready loaded contents
            wmsMapLayer.Clear();

            if (layerDesc.LayerDescriptionCount == 0)
            {
                qrylyr = (ILayer)wmsMapLayer.CreateWMSLayer(layerDesc);
                wmsMapLayer.InsertLayer(qrylyr, 0);
            }
            else
            {
                qrylyr = (ILayer)wmsMapLayer.CreateWMSGroupLayers(layerDesc);
                wmsMapLayer.InsertLayer(qrylyr, 0);
            }
            makeCompositeLayersVisibile(qrylyr);

            wmsMapLayer.Expanded = true;
            ((IWMSMapLayer)wmsMapLayer).BackgroundColor = new RgbColor() { NullColor = true };
            wmsLyr = (ILayer)wmsMapLayer;
            wmsLyr.Name = serviceDesc.WMSTitle;
            wmsLyr.Visible = true;

            return wmsLyr;
        }
Example #13
0
        public static ILayer getWMSasLayer(string WMSurl)
        {
            IPropertySet propSet = new PropertySetClass();
            IWMSConnectionName connName = new WMSConnectionNameClass();
            IWMSGroupLayer wmsMapLayer = new WMSMapLayerClass();
            IDataLayer dataLayer = (IDataLayer) wmsMapLayer;
            IWMSServiceDescription serviceDesc;

            //connect to url
            propSet.SetProperty("URL", WMSurl);
            connName.ConnectionProperties = propSet;
            dataLayer.Connect((IName)connName);
            //get service description
            serviceDesc = wmsMapLayer.WMSServiceDescription;

            ILayer wmsLayer = (ILayer)wmsMapLayer;
            wmsLayer.Visible = true;
            wmsMapLayer.Expanded = true;
            wmsLayer.Name = serviceDesc.WMSTitle;
            makeCompositeLayersVisibile( wmsLayer);
            return wmsLayer;
        }
Example #14
0
        /// <summary>Add a WMS to the map</summary>
        /// <param name="map">The map to add the wms to</param>
        /// <param name="WMSurl">the url point to the WMS</param>
        public static void addWMS2map(IMap map, string WMSurl, short transparency = 0)
        {
            IWMSGroupLayer wmsLayerGroup = new WMSMapLayerClass();
            IWMSConnectionName WMSconnName = new WMSConnectionNameClass();
            IName WMSname;
            bool succes;
            IWMSServiceDescription serviceDesc;
            IDataLayer dataLyr;
            ILayer lyr;
            IActiveView view;

            IPropertySet props = new PropertySetClass();
            props.SetProperty("URL", WMSurl);
               // props.SetProperty("VERSION", "1.3.0");

            WMSconnName.ConnectionProperties = props;
            dataLyr = (IDataLayer)wmsLayerGroup;

            WMSname = (IName)WMSconnName;
            try
            {
                succes = dataLyr.Connect(WMSname);
            }
            catch (Exception e)
            {
                MessageBox.Show("Error op wms: " + WMSurl +"\n"+ e.Message + ": " + e.StackTrace);
                return;
            }

            if (!succes)
            {
                MessageBox.Show("Kan onderstaande WMS niet openen. \n" + WMSurl);
                return;
            }

            serviceDesc = wmsLayerGroup.WMSServiceDescription;

            wmsLayerGroup.Expanded = true;
            lyr = (ILayer)wmsLayerGroup;
            lyr.Name = serviceDesc.WMSTitle;

            ILayerEffects layerEffects = (ILayerEffects)lyr;
            layerEffects.Transparency = transparency < 100 ? transparency : (short)100;

            map.AddLayer(lyr);
            view = (IActiveView)map;

            makeCompositeLayersVisibile(lyr);

            view.ContentsChanged();
        }
        private static WMSMapLayerClass CreateWmsMapLayer(string id, int attempt = 0)
        {
            var wmsMapLayer = new WMSMapLayerClass();

            // create and configure wms connection name, this is used to store the connection properties
            IWMSConnectionName pConnName = new WMSConnectionNameClass();
            IPropertySet propSet = new PropertySetClass();

            // create the idaho wms url
            var idahoUrl = string.Format(
                "http://idaho.geobigdata.io/v1/wms/idaho-images/{0}/{1}/mapserv?",
                id,
                token);

            Jarvis.Logger.Info("Adding WMS Layer to: " + idahoUrl);

            // setup the arcmap connection properties
            propSet.SetProperty("URL", idahoUrl);
            propSet.SetProperty("VERSION","1.3.0");
            pConnName.ConnectionProperties = propSet;

            //uses the name information to connect to the service
            IDataLayer dataLayer = wmsMapLayer;
            try
            {
                dataLayer.Connect((IName)pConnName);
            }
            catch (Exception e)
            {

                Jarvis.Logger.Error("Problems connecting to WMS: " + e.Message);

                if(attempt <= 5)
                {
                    Thread.Sleep(500);
                    attempt += 1;
                    return CreateWmsMapLayer(id, attempt);
                }
                return null;
            }

            return wmsMapLayer;
        }