Only get first level of WMS layers from an URL

515
2
01-30-2023 06:59 AM
SalvadorApltp
New Contributor III

Hello, everyone.

I am trying to access a list of Layers from a WMS, but instead of getting all of the layers in a treelike structure, I am getting all of them in a flat hierarchy.

WmsLayer.getLayerNames();

Will return all of the layers. But I am only interested in the fist level, not all of them.

I am using this free french service:  https://api2.geofoncier.fr/api/referentielsoge/wxs

Opening it in QGIS will show a nested structure. I am looking for something similar, to allow the user to select a group of layers and hiding the nested layers within, instead of all of the layers in a flat hierarchy.

If a nested structure is not possible, is there any way I can know which layers belongs to what, and if they are a layer group? 

Thank you kindly.

0 Kudos
2 Replies
RamaChintapalli
Esri Contributor

Hi,
You would need to get the required details from the WmsSublayers , it provides data necessary for building a Table of Contents and manage visibility of sublayers.

0 Kudos
SalvadorApltp
New Contributor III

Hello, Rama.

Thank you very much. I missed that the Sublayers had to be obtained after the WMS layer had to be loaded, not before.

I have obtained the level 0 of the WMS service, but further sublayers are not able to be obtained, despite knowing that the WMS has more layers.

wmsSublayer.getSubLayerContents() returns an empty list. Am I doing something wrong?

Thank you kindly for your support and time spent replying. I do appreciate it.

0 Kudos