I want to fetch all layers that a Web map uses from a Map service.
If I have a Web map with a Map service - the Map service contains 10 layers but only 5 of them are used in the Web map. How do I fetch these in the API?
Here is my code for fetching the Web map, but it only gets the Map services, nothing about wich layers in the Map service that are used:
from arcgis.gis import GIS
from arcgis.mapping import WebMap, WebScene
gis = GIS(url="https://geoportal.website.se/portal/", username="*****", password="****")
web_maps = gis.content.search(query="", item_type="Web Map", max_items = 5)
for map in web_maps:
maptitle = map['title']
mapid = map['id']
web_map = WebMap(gis.content.get(map.id))
layers = web_map.layers
for layer in layers:
layerType = layer.layerType
url = layer.url
itemId = layer.itemId