Select to view content in your preferred language

Web map content

2632
4
06-05-2017 10:03 AM
PhilipHughes
Emerging Contributor

I am trying to list the contents of all my Web maps for a user. I have a list of all the Web Maps but cannot find how to list the Web Maps content.  Each web map has a number of layers, these shown in portal but want to know how to get this list in python.

4 Replies
LeonS
by
Frequent Contributor

It looks like you can access the layers of a web map using the ArcGIS API for Python.  The section "Fix errors in web map" on this link, show an example of doing that.

Using and updating GIS content | ArcGIS for Developers 

Leon

SethLewis1
Frequent Contributor

Here's a snippet that should get you started. This will return the JSON for a given webmap or list of webmaps in your portal.

from arcgis.gis import GIS
from IPython.display import display
import pandas as pd
import json

gis = GIS('url', 'username', 'password')

webmaps = gis.content.search('', 'Web Map', max_items = 500)

for webmap in webmaps:
    print('Title ' + webmap.title, '\nWebmapId ' +webmap.id, '\nOwner ' +webmap.owner)
    webmapJSON = webmap.get_data()
    for layer in webmapJSON['operationalLayers']:
        display(layer)
GaryXiao2
Emerging Contributor

Thanks Seth! very helpful!

0 Kudos
RobertHolliday
Occasional Contributor

Finding this gem made my morning.

0 Kudos