Select to view content in your preferred language

Adding a webmap into a Story Map via Python

241
1
2 weeks ago
McKendreJay1
New Contributor

Hello,

My ultimate goal is pretty simple: I need to create a Story Map, add a web map to it, then save and publish it all from a python notebook. The documentation is unclear to me about how to accomplish this. Here "m" is my webmap object created in a prior process and "wmTitle" is stored in a variable. When I try to run this, it claims that object has no attribute "add." I've initiated the storymap library with

"from arcgis.apps.storymap import StoryMap"

## CREATE A STORYMAP
storymap_item = oig_gis.content.add({"type": "StoryMap",'title': wmTitle} , owner = 'mjay@xyzxyzxy')
storymap_item.share(everyone=False)

# Add WebMap to StoryMap
new_node = storymap_item.add(m, "GPS Tracking Points", "Subtitle")
storymap_item.save
storymap_item.publish
 
Also, it creates the StoryMap but does not create a REST endpoint for some reason, because going in manually and trying to edit leaves me with a 404 screen.

 

Please help, I've tried going the cloning route and that's not working either. I've pored over the class arcgis.apps.storymap.story_content.Map() documentation and it doesn't tell me anything.

 

Thanks!

Tags (3)
0 Kudos
1 Reply
TonyAlmeida
MVP Regular Contributor

At a quick glance, storymap_item.save does not actually execute the save — it just references the method object.

In Python, methods need parentheses to run. So:

storymap_item.save → just points to the function in memory (no effect).

storymap_item.save() → calls the function, performs the save.

https://developers.arcgis.com/python-2-3/api-reference/arcgis.apps.storymap.html?

save(title=None, tags=None, access=None, publish=False)

This method will save your Story Map to your active GIS. The story will be saved with unpublished changes unless publish parameter is specified to True.

 

Same with publish:

storymap_item.publish # does nothing
storymap_item.publish() # actually publishes

https://developers.arcgis.com/python-2-3/api-reference/arcgis.gis.toc.html#arcgis.gis.Item.publish

publish(publish_parameters=None, address_fields=None, output_type=None, overwrite=False, file_type=None, build_initial_cache=False, item_id=None, geocode_service=None, future=False)