Within a workflow, how do I get the collection of layers displayed in the Layers data frame?
I have a map with feature layers and cached image layers. From within a workflow, I need to grab the list of layers dispalyed in the Layers data frame and perform a task on the list. How do I access this collection of layers from my workflow?
0
-
Hi Scott,
We actually do not have an activity that grabs a list of existing layers in the viewer, so you would have to create your own workflow to do this. You have a few options:
1. You can hardcode in a list of layer names that you know are in the viewer and use that to perform a task. This is probably the easiest method.
2. You can set a property for all the layers in your viewer. That property is set under Site > Map > Layer List > Edit Layer > scoll to the bottom to click on a link called Properties:
If you click on that, you can enter a Property and Value. The value can be left blank if you want because only the property name is important in this case. Once you add in this parameter to all your layers, you can then use the GetLayerInfoByProperty activity to extract all the layers from the viewer. This method will also allow you to extract information like layer visibility, map service Id, layer URL, layer name, etc.
3. You can retrieve the layer list dynamically by feeding the Essentials REST endpoint of the site to the WebRequest activity. This will return the source code (HTML) of the page which you can then parse to extract the information you are looking for.
Out of the 3 options, I think number 2 is probably the best method to use for extracting layer information. It takes a bit of work to add a Property to all your layers, but once you do that, it becomes very easy to configure everything in the workflow.
I hope this helps.
Carmen0 -
Is anything like this available yet? I have a workflow that selects layers based on a boundary from another layer which I then want to be able to export any layers that are in the search collection.
0
Please sign in to leave a comment.
Comments
2 comments