Hello Everyone,
I have list of WebMap with its Item id's, Is is possible to save the items information as JSON file for backup and can be used later to update the WebMap. How can I save the list of WebMap items information as JSON using ArcGIS API python ??
Thank you.
Solved! Go to Solution.
When you get a web map's properties, you can simply use the json module to conver the properties dict to JSON, then write that to a file.
Can you elaborate on what your list looks like? Is it just a list of itemIDs?
Assuming you have a list of ids as strings, you could do something like this:
from arcgis import GIS
gis = GIS('your portal url')
maps = ['list', 'of', 'itemids']
out_dir = 'output directory'
for m in maps:
prop = gis.content.get(m).get_data()
with open(f'{out_dir}/{m}.json', 'w') as file:
file.write(json.dumps(prop))
Which results in something like the following (ignore that 'test.gdb' item):
Any of which, if you opened up, would have the full JSON of the web map.
When you get a web map's properties, you can simply use the json module to conver the properties dict to JSON, then write that to a file.
Can you elaborate on what your list looks like? Is it just a list of itemIDs?
Assuming you have a list of ids as strings, you could do something like this:
from arcgis import GIS
gis = GIS('your portal url')
maps = ['list', 'of', 'itemids']
out_dir = 'output directory'
for m in maps:
prop = gis.content.get(m).get_data()
with open(f'{out_dir}/{m}.json', 'w') as file:
file.write(json.dumps(prop))
Which results in something like the following (ignore that 'test.gdb' item):
Any of which, if you opened up, would have the full JSON of the web map.
Hello Josh Carlson,
Thank you for the input. The list looks like below with 56 map id's in a file
Does this kind of input can be used ??
What should be given in the below variable maps ?
maps = ['list', 'of', 'itemids']
Does this also saves the legends of the Maps ??
Thank you.
Yes, it can certainly be used. You should refer to python's read method for more information about how to do that.
A map's legend is based on layer symbology, which is defined in the JSON, so yes, the legend will be the same.