In this blog post, we will look at how to use ArcGIS API for Python to list all offline map areas and their related items in all web maps of a specific ArcGIS Online account.<\/P>
from arcgis.gis import GISfrom arcgis.mapping import WebMapgis = GIS(username='<developer>')webmap_items = gis.content.search(query="type:'Web Map'")for webmap_item in webmap_items: webmap = WebMap(webmap_item) map_area_items = webmap.offline_areas.list() for map_area_item in map_area_items: header = f"'{webmap_item.title}' has an offline map area named '{map_area_item.title}' sharing the 'Area2Package' relationship with:" print(header) for rel_item in map_area_item.related_items('Area2Package', 'forward'): print(f'\t{rel_item.title}\n\t\t{gis.url}\/home\/item.html?id={rel_item.id}\n\t\t{rel_item.type}') print('\n')<\/code><\/pre>'Bonn WebMap' has an offline map area named 'Bonn WebMap_MapArea' sharing the 'Area2Package' relationship with: Vector-8795e9d21ed7456c90e332c7a363bfdd https:\/\/<organization>.maps.arcgis.com\/home\/item.html?id=422affa753fc4a378f9dea691d5f3047 Vector Tile Package<\/code><\/pre> <\/P> <\/P>Script Explanation<\/H2>This script iterates through all web maps and lists for each map all offline map areas and their related portal items. The 'Area2Package' relationship indicates that the map area was exported as a package for offline use. The related portal items were created as packages from the map areas.<\/P>Conclusion<\/H2>ArcGIS API for Python enables the automation of complex tasks such as listing offline map areas and their related portal items. With a little Python, we can leverage this API to make our work with ArcGIS more efficient and effective.<\/P>I hope this blog post was helpful! If you have any questions or comments, do not hesitate to ask. Happy Mapping!<\/P>
'Bonn WebMap' has an offline map area named 'Bonn WebMap_MapArea' sharing the 'Area2Package' relationship with: Vector-8795e9d21ed7456c90e332c7a363bfdd https:\/\/<organization>.maps.arcgis.com\/home\/item.html?id=422affa753fc4a378f9dea691d5f3047 Vector Tile Package<\/code><\/pre> <\/P> <\/P>Script Explanation<\/H2>This script iterates through all web maps and lists for each map all offline map areas and their related portal items. The 'Area2Package' relationship indicates that the map area was exported as a package for offline use. The related portal items were created as packages from the map areas.<\/P>Conclusion<\/H2>ArcGIS API for Python enables the automation of complex tasks such as listing offline map areas and their related portal items. With a little Python, we can leverage this API to make our work with ArcGIS more efficient and effective.<\/P>I hope this blog post was helpful! If you have any questions or comments, do not hesitate to ask. Happy Mapping!<\/P>
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.