0

I have developed a new toolbar Add-In for ArcGIS Pro 2.4 with C# and ArcGIS Pro SDK in Visual Studio 2019. This toolbar has several buttons that load geographic information to a map canvas in ArcGIS Pro.

One button should display a WMS layer using a WMS service URL to ArcGIS Pro, but I am not able to load only one sublayer rather than all sublayers contained in a WMS service.

Up to now, I have this code: https://community.esri.com/docs/DOC-8802-how-to-add-a-wms-service-to-arcgis-pro-using-the-sdk

 using ArcGIS.Core.CIM;
 using ArcGIS.Desktop.Framework.Threading.Tasks;
 using ArcGIS.Desktop.Mapping;

 // Create a connection to the WMS server
 var serverConnection = new CIMInternetServerConnection {URL = "Fill in the URL of the WMS service"};
 var connection = new CIMWMSServiceConnection {ServerConnection = serverConnection};

 // Add a new layer to the map
 await QueuedTask.Run(() => 
 {
      var layer = LayerFactory.CreateLayer(connection, MapView.Active.Map);
 });

I cannot find methods of CIMInternetServerConnection class or CIMWMSServiceConnection class where to set the WMS sublayer name to load.

By other hand, I have found this sample code for ArcGIS Runtime SDK for .NET: https://developers.arcgis.com/net/latest/wpf/sample-code/wms-layer-url/

This is part of the sample code:

    private void Initialize()
    {
        // Create a map with basemap and initial viewpoint.
        Map myMap = new Map(Basemap.CreateLightGrayCanvas())
        {
            // Set the initial viewpoint.
            InitialViewpoint = new Viewpoint(
                new Envelope(-19195297.778679, 512343.939994, -3620418.579987, 8658913.035426, 0.0, 0.0, SpatialReferences.WebMercator))
        };

        // Add the map to the mapview.
        MyMapView.Map = myMap;

        // Create a new WMS layer displaying the specified layers from the service.
        WmsLayer myWmsLayer = new WmsLayer(_wmsUrl, _wmsLayerNames);

        // Add the layer to the map.
        myMap.OperationalLayers.Add(myWmsLayer);
    }

Is there any class in ArcGIS Pro SDK like the WmsLayer class showed in this example?

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.