Hi @fklotz ,
Nice script, saved me a lot of time writing it myself.
Small improvement at line 30:
for lyr in lyrs:
if 'url' in lyr and not found_it:
found_it = lyr_to_find.lower() in lyr.url.lower()
elif 'layerType' in lyr and lyr.layerType =="GroupLayer":
for sublyr in lyr.layers:
if 'url' in sublyr and not found_it:
found_it = lyr_to_find.lower() in sublyr.url.lower()
I got an exception when it found a layer in my GIS without url. The first part of the if statement fixes this. And it should stop searching the webmap when it already found a match, otherwise another layer in the webmap might set the found_it variable to False again, the second part of my if statement should fix that.
Edit: added support for the new Map Viewer Group Layers. Noticed that the script didn't find a map and this was due to a group layer.
Another Edit: found a case where an url was not found, because part of it was in uppercase. Updated my snippet to take care of this
-Joël Hempenius.
Languages: JavaScript, Python and Dunglish