1

I've been reading through the help and readme.md and playing with the configuration options for the CMV LayerControl and I'm pretty confused by the possibilities. It seems to me there are at least 2 if not 3 places where configurations can be set for this control.

The first choice seems to be where you configure the widget in viewer.js in the widgets.layerControl.options. In the "options" object you can add "Control Options" configuration attributes such as "exclude", "noLegend", "noZoom", "noTransparency", "swipe", "swipeScope", "expanded", "sublayers", "metadataUrl", "allSublayerToggles". Setting it here would affect all service "layers".

The next place where you can do some configuration is the viewer.js in the operationalLayers[].layerControlLayerInfos object. It looks like here you can also add some "Control Options" at the service "layer" level. This would affect each service "layer" independently.

The final place, and this is what I'm most confused about, it appears that you can create your own LayerInfos array of LayerInfo objects to customize the Layer Control for each GIS "layer" (ie. sub-layer in a Dynamic Map Server Layer)?

Maybe I'm just wishing this to be the case.

Can someone confirm that?

Where would you use the LayerControl Class?

I guess that would be if you wanted to add the LayerControl widget to the DOM in a some other location?

Can you do anything with sub-layers in a Dynamic Map Service Layer?

closed as too broad by PolyGeo Jan 23 '18 at 22:50

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

4

I think you correctly understand the first two options. You can specify options at the widget level (global options) which will be applied to all operational layers and you can specify the same options at the individual operational layer level to override widget level configuration.

Finally, you can also use the LayerControl in your own widget by instantiating it directly inside your own widget. When taking this approach, you will need to pass the constructor an object which contains a reference to the map and an array of layerInfos. You could configure your widget to receive a reference to the layerControlInfos or you could build them yourself.

Here's an example of instantiating a LayerControl widget in the postCreate method of a custom widget:

postCreate: function () {
    this.layerControl = new LayerControl( { map: this.map, layerInfos:   [ {
            layer: this.layer,
            separated: false,
            title: 'Layer Title',
            type: 'dynamic',
            controlOptions: {
                noLegend: false,
                noZoom: true,
                noTransparency: false,
                sublayers: true,
                swipe: true,
                swipeScope: true,
                expanded: true                                                     }
        } ] } )
}

You might do this to leverage the LayerControl widget to manage a dynamic map service your widget adds to the map.

As another example, you might want to use separate instances of the LayerControl widget to control subsets of the operational layers. In this case you would configure your widget to receive a reference to the layerControlLayerInfos array and then filter that array and pass that to the LayerControl constructor.

In response to your question about doing anything with dynamic sub layers, LayerControl will allow you to toggle them on/off and has menu item for turning all sub layers on/off. You could also treat individual sub layers as FeatureLayers which LayerControl can control but that approach has some gotchas as well. For instance, certain types of symbology might be slightly different.

Not the answer you're looking for? Browse other questions tagged or ask your own question.