Cloning and Editing StoryMaps
In this guide we will walk through the process of cloning a storymap within our organization and to another organization. We will then edit the cloned story and copy selective content elements from the cloned story to the original story. We have a separate Introduction to StoryMaps guide that covers the various content elements that can be added to a StoryMap.
from arcgis.gis import GIS
from arcgis.apps import storymap
from arcgis.apps.storymap import StoryMap, Themes, Cover
from arcgis.apps.storymap.story_content import Image, Image360gis = GIS(profile='your_online_profile')We fetch the StoryMap item we would like to clone.
storymap_item = gis.content.get('7860d45d35f6455193576933206d8352')my_story = StoryMap(storymap_item)
my_storyDuplicating a StoryMap
The duplicate() method supported specifically for StoryMap items lets you create a copy or shallow clone of your StoryMap. It retains the structure, text and layout of the original story but does not clone the items within the original story and retains references to the maps, layers, and other items from the original story. The duplicate() method is a powerful way to create a copy of your story within the same organization.
duplicated_story = my_story.duplicate("Duplicated nature story 1")
duplicated_storyOn the other hand, if you wish to clone this story while also cloning the deep dependencies (e.g., maps, layers, tables) from the original story, you will need to use the clone_items() method of the ArcGIS API for Python.
This technique is particularly potent to clone the StoryMap and its dependencies to another organization, as shown in the example that follows.
Cloning to ArcGIS Enterprise
gis_enterprise = GIS(profile='your_enterprise_profile')cloned_story_ent = gis_enterprise.content.clone_items([storymap_item])
cloned_story_ent[<Item title:"Nature WebMap" type:Web Map owner:mmajumdar>, <Item title:"Nature Themed Story" type:StoryMap owner:mmajumdar>]
clone_items() has successfully cloned both the the StoryMap and Web Map items to the target ArcGIS Enterprise organization.
Editing the StoryMap
We will now make edits to certain aspects of our cloned story. You can make edits to update the branding elements of the Storymap, as we will see below.
Additionally, you can make edits to update the content elements. This can be particularly useful when you have a template Storymap and you want to clone it to retain the structure and layout but only update the text or maps or media within the story.
cloned_storymap = StoryMap(cloned_story_online[1])img = Image("https://www.nps.gov/npgallery/GetAsset/69680c29-caa3-42da-93d9-32925e9ed409/proxy/hires")Cover
The cover is what you see at the start of your StoryMap. This cover can set the visual tone of the StoryMap.
We will update necessary attributes for the cover.
cover = cloned_storymap.contents[0]
cover.title = "Nature Story"
cover.summary = "Nature themed StoryMap"
cover.byline = "Python Story"
cover.media = imgcloned_storymap.save()Having saved this story, we now see the cover updated.
Logo
Similarly you can also update the logo of the story.
cloned_storymap.set_logo('D:/Github Projects/geosaurus/tests/resources/storymap/storymap_image_river.jpg')True
Theme
Theme sets the visual style and appearance of the StoryMap. ArcGIS StoryMaps supports the following themes:
The ArcGIS API for Python supports these themes through type enumerations which include:
SUMMIT= "summit"OBSIDIAN= "obsidian"RIDGELINE= "ridgeline"MESA= "mesa"TIDAL= "tidal"SLATE= "slate"
You can fetch and update the theme of your story as shown below.
cloned_storymap.get_theme()'summit'
cloned_storymap.theme(Themes.OBSIDIAN)<Themes.OBSIDIAN: 'obsidian'>
It is necessary to save the StoryMap to see our changes reflect there.
cloned_storymap.save()The theme of the story has been successfully updated.
Credits
Credits represent the attribution section in a story. Credits are found at the end of the story and thus are always the last node.
cloned_storymap.credits(content="Nature story" , attribution="ArcGIS API for Python", heading="Nature themed story", description="Generated through Python")['n-9087a8']
my_story.credits(content="Nature story" , attribution="ArcGIS API for Python", heading="Nature themed story", description="Generated through Python")['n-GYl04j', 'n-386ede', 'n-477910']
cloned_storymap.save()This has successfully updated the credits towards the end of the story.
Editing text
Let us look at a final example where we update some text within the cloned story.
We identify the particular content element with text we would like to update by providing the index of that content element to the contents property of the StoryMap.
content = cloned_storymap.contents[3]
content.text'Nature themed story'
content.text = 'Flora and Fauna story'cloned_storymap.save()Adding a new map to my Storymap
We now fetch the map item that we would like to include in this story. Having imported the storymap submodule previously, we can directly access the Map class within it, specific for StoryMap content, as shown below.
You can learn more about the other supported StoryMap content elements from this introductory guide.
map1 = gis.content.get('7f39672ef7f6469db7b2bbd383349fc1')
map1_for_storymap = storymap.Map(map1)cloned_storymap.add(content = map1_for_storymap, caption = "Natural Beauty in UK", position = 4)True
cloned_storymap.save()Copy selective content over to a another Storymap
The ArcGIS API for Python also allows for copying selective sections of a StoryMap over to another using the copy_content() method if you do not wish to clone all the content of a StoryMap.
This capability can be beneficial in a few cases.
- You may have cloned an existing story, updated it with a few more content elements and would like to copy those over back to the original StoryMap.
- You may already have another StoryMap item that you would like to update with content from your existing StoryMap, without cloning it and creating another item.
We will explore the second use-case through an example below.
Note: If you wish to copy all the content elements of a StoryMap, you need to ensure that you are not copying the Cover, Navigation and Credits of one story over to another. We will see how to remove those elements before copying below.
content = cloned_storymap.contents[2:]
content[Image360(image='storymap_image_river.jpg'), Text(text=Flora and Fauna story), Map(item='7f39672ef7f6469db7b2bbd383349fc1', type='Web Map'), Image(image='https://www.nps.gov/npgallery/GetAsset/69680c29-caa3-42da-93d9-32925e9ed409/proxy/hires'), ImageGallery(num_images=3), Separator(), Audio(path='rocks.mp3'), Video(path='https://www.youtube.com/embed/8wY14zHDmEs'), Sidecar(num_slides=1), Swipe(type='image'), 'Credits']
Filtering the contents from index 2 and onwards removes the Cover and Navigation. We now remove the Credits.
content.pop(-1)'Credits'
We fetch the StoryMap to which we would like to content copy over.
python_story = gis.content.get('2c1eb8f9a4c44b3ea6ed2af554f394a2')
python_storymap = StoryMap(python_story)
python_storymapcloned_storymap.copy_content(target_story = python_storymap, node_list = content)True
Ensure that you save the target_story after copying content into it for the changes to reflect in the story.
python_storymap.save()