Clone Items and setting new Item Extent

08-10-2021 10:33 AM
New Contributor II

Hi all, 

I am trying to clone a Web App but have it centered over a  new area (new city for example) and i was wondering if I could use the item_extent parameter from clone_items to achieve this. Anyone have any ideas?



1 Reply
New Contributor

I would also like to get some more information on this. I can't find anything online. I've tried the following, but when I open the cloned WebMap, the extent remains unchanged:

ext ={'spatialReference': {'latestWkid': 3857, 'wkid': 102100},
      'xmin': -1252724.3668020056,
      'ymin': 4250996.361644156,
      'xmax': -84766.57460482302,
      'ymax': 4740193.342669154}

cloned_item = mygis.content.clone_items(items=[temp_item],


I have tried to this before with copy_item() as well, since I'm not moving content between portals and organizations. I just need to duplicate a webmap and then reset the extent. But not a single approach has worked for me:

#Copy the item, move and share the copy
new_item = temp_item.copy_item(title="WMasdf_{}".format(event_name), folder = event_name)
new_item.move(event_name) #because the folder parameter in the previous method doesn't seem to work either

#Different formats of extents
ex1 = {'xmin': -427248.44528862747, 
      'ymin': 4919558.2636672305, 
      'xmax': -399769.33362014365, 
      'ymax': 4936393.519147017, 
      'spatialReference': {'latestWkid':3857,
                           'wkid': 102100}}
ex2 = '-427248.44528862747, 4919558.2636672305, -399769.33362014365, 4936393.519147017'
ex3 = '110, 47, 111, 46'
ex4 = [[110,47],[111,46]]

#Differente ways I've been trying to set the extent, some on their own, then also some combined. Nothing worked
new_item.extent = ex4

new_item.get_data()['initialState']['viewpoint']['targetGeometry'] = ex



new_map = WebMap(copy_item)
new_map.definition['initialState'] = ex

If someone could offer some insight on this, that would be amazing!


0 Kudos