how to get all layer ids of web map?
I would like to have a dropdown on a form, list all layer names from current web map, the host application for this workflow is web AppBuilder. I saw there is out-of-box "get layer "activity there by specifying layer id, but I don't know possible layer IDs, since this workflow is designed for general use, and the web map would get layers from multiple feature /map services. Any advice for me on how to get all layer ids of a web map? Thanks a lot !
-
Hi Hua,
If you use the Get Map activity, you should be able to gather the available layerIds through a loop of the =$map1.map.layerIds[X] and supply them to the Get Layer activity and obtain the layer names.
Thanks, Stefan
0 -
hi Stefan,
Thanks a lot for your quick reply. I have looked Get Map activity , it looks to me layerIds property is not exposed out to use. if I log =$map1.map.layerIds, I got undefined value. I am using on-premise workflow designer, and run in sandbox for testing purpose. Thanks again!
0 -
Hi Hua,
No worries. The layerIds property is an array, which is why I suggested using a loop to iterate through them. If you use a Log activity with =$map1.map as an input, you can open the browser console and expand this element to see all of its properties and values.
Thanks, Stefan
0 -
Hi Stefan, Thanks again for your quick response. Yes, I was able to log =$map1.map and use F12 to see all properties and values there. why not log to watch an array? I have created a test workflow as attached to loop through layerIds, still no luck. Any thing I am missing? I am attaching my simple test workflow in json, would you have a try? I took out my server name from licenseUrl there. I am using the latest on-premise workflow designer and run in sandbox on the designer. Do appreciate your help! With best Hua Hua Wan | Lead Developer Esri Canada | 900-12 Concorde Pl | Toronto ON M3C 3R8 T 416-386-6422 | esri.ca 0 -
Hi Hua,
Looks like you missed uploading the workflow?
Stefan
0 -
I did upload my workflow in json format. I am uploading this time .zip file. Hope that you can receive it. Thanks a lot! Hua Wan | Lead Developer Esri Canada | 900-12 Concorde Pl | Toronto ON M3C 3R8 T 416-386-6422 | esri.ca 0 -
I'm not seeing any of those docs listed here.
Are you uploading them using the small clip in the bottom left corner?
0 -
I replied the email with my attachment there. Here you go and sorry for this confusion. Thanks!
0 -
Hi Hua,
I've updated the workflow and reattached it. The object returned by the Get Map activity actually has another .map property, so to reach the layerIds, you'll use =$map1.map.map.layerIds in the For Each.
Thanks, Stefan
0 -
Hi Stefan, It works fine now. Thanks a lot for your help! Hua Hua Wan | Lead Developer Esri Canada | 900-12 Concorde Pl | Toronto ON M3C 3R8 T 416-386-6422 | esri.ca 0 -
hi Stefan,
A further question: in order for me to get layer's url, I add "Get Layer" Activity by passing "=$forEach1.item" on "Layer Id" inside the loop, the workflow threw me an error. Any idea? please refer to the attached codes. Thanks a lot!
0 -
What specific errors are you seeing?
You can add a Try Catch activity to handle any errors that are thrown that are unexpected..
0 -
hi Stefan,
I have added Try Catch activity, didn't get an error, actually return "undefined" value after apply "Get Layer" activity inside the loop. For a feature layer of web map, it is listed under "=$map1.map.map.graphicsLayerIds". and for a map layer of web map, it is listed under "=$map1.map.map.layerIds". Would you have a look at my attached codes, not sure what I am missing? Again, you would run in sandbox and I am using on-premise workflow designer. thanks a lot!
0 -
I have fingered it out. To get all feature layer Ids of web map, use "=$map1.map.map.graphicsLayerIds", then use get "Get Layer Property" activity inside a loop to get layer properties such as url, name, layer type. not sure why "get layer" activity is not working for me. or use =$map1.map.map._layers to get details for all layers of current web map. Thanks!
0
Please sign in to leave a comment.
Comments
14 comments