Toggle Layers On/Off

2282
1
Jump to solution
10-09-2015 02:05 PM
PatrickWild3
New Contributor III

Can someone provide an example for toggling FeatureLayers on/off?

I would also like to ave the option of switching between my basemaps that are LocalTiledLayers, is this possible?

I thought I saw an example but I cannot find it now.

Thanks,

PW

0 Kudos
1 Solution

Accepted Solutions
PatrickWild3
New Contributor III

The Simple Renderer Online sample was the one I was looking for.

Add a check box for each layer:

CheckBox {
                               id: topoCheckBox
                               text: qsTr("Topo")
                               checked: true
                               onCheckedChanged: {
                                   updateVisibility(topo, checked);
                               }
                           }

Include the function:

function updateVisibility(layerId, visible) {

           layerId.visible = visible;

}

Seems to work fine with ArcGISTiledMapServiceLayer, ArcGISLocalTiledLayer, and FeatureLayer

PW

View solution in original post

0 Kudos
1 Reply
PatrickWild3
New Contributor III

The Simple Renderer Online sample was the one I was looking for.

Add a check box for each layer:

CheckBox {
                               id: topoCheckBox
                               text: qsTr("Topo")
                               checked: true
                               onCheckedChanged: {
                                   updateVisibility(topo, checked);
                               }
                           }

Include the function:

function updateVisibility(layerId, visible) {

           layerId.visible = visible;

}

Seems to work fine with ArcGISTiledMapServiceLayer, ArcGISLocalTiledLayer, and FeatureLayer

PW

0 Kudos