Select to view content in your preferred language

How to make a layer visible / invisible?

1478
2
Jump to solution
10-11-2021 11:28 PM
DavidMrázek
Frequent Contributor

Good day,
I have a question, how do I set my checkbox in the add-in to make the layer visible / invisible? The layer is called "selection". My code doesn't work because IsvisibleInView is read-only.

Thanks for the advice

namespace KoncoveBody
{
internal class ViditelnostVrstvy : CheckBox
{
public ViditelnostVrstvy()
{
IsChecked = true;
}

protected override void OnClick()
{
var mapView = MapView.Active;
var vrstva =
mapView.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(l => l.Name == "Vyber") as
BasicFeatureLayer;


if (mapView == null) return;
bool isLayerVisibleInView = vrstva.IsVisibleInView(mapView);
if (isLayerVisibleInView)
{
vrstva.IsVisibleInView(mapView)=false;

}
}

}
}

 

0 Kudos
1 Solution

Accepted Solutions
GKmieliauskas
Esri Regular Contributor

Hi,

You can use SetVisibility method from Layer type object

View solution in original post

2 Replies
GKmieliauskas
Esri Regular Contributor

Hi,

You can use SetVisibility method from Layer type object

DavidMrázek
Frequent Contributor

Hi,

Thank you very much that´s right!

0 Kudos