I am going to add a wms layer to my existing map.I use this code:

public load_wms(ESRI.ArcGIS.Controls.AxMapControl mapcontrol) { 

               // Create an WMSMapLayer Instance - this will be added to the map later

               IWMSGroupLayer wmsMapLayer = new WMSMapLayerClass();
               // create and configure wms connection name
               // this is used to store the connection properties

               IWMSConnectionName connName = new WMSConnectionNameClass();

                IPropertySet propSet = new PropertySetClass();
                propSet.SetProperty("URL", "");

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

               // get service description out of the layer
               // the service description contains inforamtion about the wms categories
               // and layers supported by the service

                IWMSServiceDescription serviceDesc = wmsMapLayer.WMSServiceDescription;
                IWMSLayerDescription groupDesc = serviceDesc.LayerDescription[0];

               // for each wms layer either add the stand-alone layer or
               // group layer to the WMSMapLayer which will be added to ArcMap
                for (int i = 0; i < groupDesc.LayerDescriptionCount - 1; i++)
                    IWMSLayerDescription layerDesc = groupDesc.LayerDescription[i];

                  //  if (layerDesc.Title == WMSLayers.SelectedItem.ToString())//Checking if this is the selected layer
                   // {
                        // Configure the layer before adding it to the map
                        ILayer newLayer;
                        IWMSLayer newWMSLayer = wmsMapLayer.CreateWMSLayer(layerDesc);
                        newLayer = (ILayer)newWMSLayer;
                        wmsMapLayer.InsertLayer(newLayer, 0);
                        // add layer to Map

                        IActiveView activeview=(IActiveView)mapcontrol.ActiveView;

                  //  }


But it does not draw anything I can add it to openlayers but when I add it to ArcMap it does not drow anything..Can you help me fix it I am on arcobjects 10.2.2 and arcmap 10.2.1 also

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.