How to make a layer visible / invisible?

389
2
Jump to solution
10-11-2021 11:28 PM
DavidMrázek
Occasional Contributor II

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
GintautasKmieliauskas
Regular Contributor II

Hi,

You can use SetVisibility method from Layer type object

View solution in original post

2 Replies
GintautasKmieliauskas
Regular Contributor II

Hi,

You can use SetVisibility method from Layer type object

DavidMrázek
Occasional Contributor II

Hi,

Thank you very much that´s right!

0 Kudos