ThinkGeo.com    |     Documentation    |     Premium Support

Problem with nested WMS layers

Hi,

I am trying to load WMS from the following:

https://factmaps.sodir.no/arcgis/services/FactMaps_ogc/3_0_ED50_z32/MapServer/WMSServer

If I select a layer, I get the following on the map.

I noticed when looking in QGIS that this server appears to have sub layers for the main layers unlike most sites I access. Can you advice how to get to the individual sub layers for loading?

Thanks,
Damian

Hi @Damian_Hite,

There’s something wrong with GetBoundingBox method of WmsAsyncLayer, but we could give a hard-coded bounding box to get it working. You’re able to find the layer’s corresponding bounding box in WMS_Capabilities

Here’s the code snippet:

WmsAsyncLayer layer = new WmsAsyncLayer(new Uri("https://factmaps.sodir.no/arcgis/services/FactMaps_ogc/3_0_ED50_z32/MapServer/WMSServer"));
await layer.OpenAsync();
var layers = layer.GetServerLayers();
layer.ActiveLayerNames.Add(layers[0].Name);
layer.ActiveStyleNames.Add("");

LayerOverlay overlay = new LayerOverlay();
overlay.Layers.Add(layer);
map.Overlays.Add(overlay);

map.CurrentExtent = new RectangleShape(-15.593882, 78.682921, 43.210634, 55.472608);
await map.RefreshAsync();

I’ve fixed the GetBoundingBox issue, you could call it to get the correct boundingbox once ThinkGeo.Core 14.3.0-beta034 is available.

Regards,
Leo

Hi Leo,

First, I am using v10 lib. I also don’t actually set the bounding box either.

I am thinking this is a version 10 thing. I can only use GetServerLayerNames which for some odd reason just returns a list of numbers and not actual layers that I can add as you have done.

Can you advice if there is a v10 workaround for finding layer names that are nested on the server and how I can load them using v10.

Thanks,
Damian

hi @Damian_Hite,

May I know which specific version you’re using? It works good with the following code on my side:

        winformsMap1.MapUnit = GeographyUnit.DecimalDegree;

        var wmsLayer = new WmsRasterLayer(new Uri("https://factmaps.sodir.no/arcgis/services/FactMaps_ogc/3_0_ED50_z32/MapServer/WMSServer"), WebProxy.GetDefaultProxy());
        wmsLayer.Open();
        
        var layerNames = wmsLayer.GetServerLayerNames();
        wmsLayer.ActiveLayerNames.Add(layerNames[0]);
        wmsLayer.ActiveStyleNames.Add("default");

        LayerOverlay overlay = new LayerOverlay();
        overlay.Layers.Add(wmsLayer);
        winformsMap1.Overlays.Add(overlay);

        // it still works even without this line
        winformsMap1.CurrentExtent = new RectangleShape(-15.593882, 78.682921, 43.210634, 55.472608);
        winformsMap1.Refresh();

Regards,
Leo