Hoppa till huvudinnehållet

How to toggle visibility of all layers at once?

Kommentarer

2 kommentarer

  • Bryan Price

    Hi Johanna,

    You will need to create a workflow. It will loop through the layers in the map and set their visibility to off.

    There might be a better way but here is what I have.
     

    Create Value for layers with expression: =[] 

    Set For Each Items: =$map1.map.map.allLayers.items

    In the loop Add item with collection: =$layers.result and item =$forEach1.item.title

    Finally Run Command with command name: layers.set-visibility and command parameter: ={"layers": $layers.result, "visible": false}

    You can also Run Command: map.refresh

    You can save the following as a .json file

    {"_properties":{"isServerWorkflow":false},"components":[{"id":2,"steps":[{"id":3,"inputs":{},"position":"0,0","purpose":"start","title":"Start","transitions":[{"id":37,"position":"90,60 90,120","sourceConnector":"bottom","target":{"id":16},"targetConnector":"top"}]},{"action":"gcx:wf:core::Annotation","description":"Loop through map layers","id":14,"inputs":{},"position":"240,110","title":"Get All Layers"},{"action":"gcx:wf:core::CreateValue","id":16,"inputs":{"expression":{"accessors":[],"annotations":[],"code":"[]","source":"[]"}},"name":"layers","position":"-30,120","title":"Create Value","transitions":[{"id":30,"inputs":{},"position":"90,180 90,240","sourceConnector":"bottom","target":{"id":18},"targetConnector":"top"}]},{"action":"gcx:wf:arcgis::GetMap","id":18,"inputs":{},"name":"map1","position":"-30,240","title":"Get Map","transitions":[{"id":32,"inputs":{},"position":"90,300 90,360","sourceConnector":"bottom","target":{"id":20},"targetConnector":"top"}]},{"action":"gcx:wf:core:loop:ForEach","id":20,"inputs":{"items":{"accessors":["$map1"],"annotations":[{"count":5,"index":0,"kind":"idref"}],"code":"$map1.map.map.allLayers.items","source":"$map1.map.map.allLayers.items"}},"name":"forEach1","position":"-30,360","title":"For Each","transitions":[{"id":34,"inputs":{},"position":"90,480 90,530","sourceConnector":"bottom","target":{"id":22},"targetConnector":"top"}]},{"action":"gcx:wf:core::Log","id":22,"inputs":{"message":{"accessors":["$layers"],"annotations":[{"count":7,"index":0,"kind":"idref"}],"code":"$layers.result","source":"$layers.result"}},"position":"-30,530","title":"Log","transitions":[{"id":36,"inputs":{},"position":"90,560 90,610","sourceConnector":"bottom","target":{"id":24},"targetConnector":"top"}]},{"action":"gcx:wf:app::RunCommand","id":24,"inputs":{"commandName":"layers.set-visibility","commandParameter":{"accessors":["$layers"],"annotations":[{"count":7,"index":11,"kind":"idref"}],"code":"{ \"layers\": $layers.result, \"visible\": false }","source":"{\"layers\": $layers.result, \"visible\": false}"}},"position":"-30,610","title":"Run Command","transitions":[{"id":39,"position":"90,640 90,700","sourceConnector":"bottom","target":{"id":38},"targetConnector":"top"}]},{"action":"gcx:wf:core::Annotation","description":"Turn off Layers","id":26,"inputs":{},"position":"260,620","title":"Set Layer Visibility"},{"action":"gcx:wf:app::RunCommand","id":38,"inputs":{"commandName":"map.refresh"},"position":"-30,700","title":"Run Command"}]},{"id":6,"steps":[{"id":8,"inputs":{},"position":"0,0","purpose":"start","title":"For Each","transitions":[{"id":12,"inputs":{},"position":"90,60 90,110","target":{"id":10}}]},{"action":"gcx:wf:core::AddItem","id":10,"inputs":{"collection":{"accessors":["$layers"],"annotations":[{"count":7,"index":0,"kind":"idref"}],"code":"$layers.result","source":"$layers.result"},"item":{"accessors":["$forEach1"],"annotations":[{"count":9,"index":0,"kind":"idref"}],"code":"$forEach1.item.title","source":"$forEach1.item.title"}},"position":"-30,110","title":"Add Item"}]}],"deploymentConfig":{"supportedApps":{"VSW":true}},"designerVersion":"5.50.0+14","licenseInfo":{"licenseUrl":"https://acura.kmc.nsw.gov.au/vertigisstudio/workflow/service/auth/license"},"start":{"id":3},"transitions":[{"branch":"loop","id":28,"inputs":{},"source":{"id":20},"target":{"id":8}}]}
    0
  • Johanna Batz-Finkbohner

    Hi Bryan,

    thank you very much for sharing your workflow. It works perfectly!

    0

Du måste logga in om du vill lämna en kommentar.