Accessing Visibility Property for Feature Layer

1337
6
08-30-2016 12:24 PM
NickSchneider1
New Contributor

Hello all,

I am currently trying to build a table of contents using the .net runtime and ESRI map layers. 

Using a HierarchicalDataTemplate I have bound the service layers to nodes (which contain checkboxes) on the table of contents. When a layer is loaded, the respective node and checkbox appear in the table of contents with a drop-down arrow to access all of the features within a layer.

My question is how can I access some sort of visibility property within the feature layer so that I can bind the checkboxes to the visibility of the feature layer? The closest thing I could find was a 'Default Visibility' property and a DrawingInfo.Opacity property but neither of these seem to work accordingly.

Any help is much appreciated

0 Kudos
6 Replies
AnttiKajanus1
Occasional Contributor III

You can change the visibility on and off using IsVisible property on all layers.

0 Kudos
NickSchneider1
New Contributor

Unfortunately, Feature Layers do not have the IsVisible property!

0 Kudos
AnttiKajanus1
Occasional Contributor III

FeatureLayer derives from layer class and it is there. Curious why you aren't able to see it then.

0 Kudos
NickSchneider1
New Contributor

I can, also, see the IsVisible property for a FeatureLayer, but I have yet to find a way to access the Feature Layer through the Service Layer. Within the Service Layer is ServiceInfo which holds properties for the Feature Layers but does not give the ability to access visibility, because it is info type and not a layer type.

0 Kudos
AnttiKajanus1
Occasional Contributor III

What do you mean by Service Layer? I assume that you have ServiceFeatureTable which has ServiceInfo about the backing Feature Service on the server. To show features in a map you would be using FeatureLayer that points to that ServiceFeatureTable (can be found from FeatureTable property in a FeatureLayer). FeatureLayer is the part that is responsible of showing the data (view) where the FeatureTable is handling the communication between the service and the client.

If you have bound your control which is changing the Map.Layers collection you should have access to all layers in the map including FeatureLayers. Have a look on layer list sample too.

0 Kudos
ChristinaKochan1
Occasional Contributor

I suppose you could just use the SetFeatureVisibility method when your checkbox is changed and apply the change to all features.

We actually ended up loading all of our feature layers using an ArcGISDynamicMapServiceLayer created from a LocalMapService. It's more consistent with the rest of the data files we add to the map and that way all of the layers have the same properties available. It is kind of weird in that you have to add the layer ID to the VisibleLayers collection to make it visible, but at least a way to do it does exist.

It would make a lot more sense for all of the layer types in the Runtime SDK to inherit from the Layer class, though, wouldn't it?

0 Kudos