But, in order to get/set the visibility of its sublayer it takes Layerid as an argument which is not public. The question here is how can I use this method unless I have the Layerid.
SetLayerVisibility(int layerID, bool visible);
Same is the issue with MaximumScale and MinimumScale. Please suggest me a proper way to handle this situation.
How exactly do you set the visibility of WMS sub layer using Wms.Layers property?
The 'Layers' property is of type string[].
You can set it in XAML though a comma separated layer list:
<esri:WmsLayer Layers="layer1,layer2" .....
or in C# by code like:
wmsLayer.Layers = new[] { "layer1", "layer2"};
If you need to know dynamically the list of layers supported by the service you can use the LayerList property
Thanks Dominique - I can add the WMS successfully, using
<esri:WmsLayer Layers="layer1,layer2"
.. but default visibility on the WMS sub layers is false.
How do I programmatically turn on visibility for a WMS sub layer in c#?
Visibility of WMS layers should be depending on the list of Layers you set.
From the moment you set Layers to "layer1, layer2", these sublayers should be visible (and all ascendants and descendants as well if you are working with a hierarchy of sublayers).
You should be able to observe that by setting up a legend control that displays the sub layers visibility such as in this sample.
In synthesis:
- to change programmatically the layer visibilities --> set the 'Layers' property
- to change interactively these visibilities --> use the legend control
Ok got it. I was providing wrong layer name. What was confusing was even if I put gibberish in there, the WMS sub layers appear properly in the TOC with visibility off. When I provide correct layer name, it appears in the map, and the TOC with visibility on, so good news.
But now I have a new WMS visibility problem. The WMS extent covers a US state. When I pan the map so that state is no longer in view, then I get a blank map with text at upper right that says "no data for requested layers". Any ideas for how to work around that? This is a google maps engine WMS.
This is a google maps engine WMS.
My best suggestion --> Use ArcGIS Server 🙂
Else you can try to set the full extent of the WmsLayer (by using the SetFullExtent method) with the envelope of the state covered. This should prevent from sending image requests to the server when the state is not in the view (not tested though)
Right 🙂 ... unfortunately this does not work:
WMSlayer.SetFullExtent (New ESRI.ArcGIS.Client.Geometry.Envelope(-14014336.9175627, 2078853.04659498, -8279569.89247312, 5078853.64659498))
... but is that the correct way to set full extent for a wms layer?