<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Clone Items and setting new Item Extent in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/clone-items-and-setting-new-item-extent/m-p/1269894#M8520</link>
    <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/454604"&gt;@JLBlair&lt;/a&gt;&amp;nbsp;Thank you so much. I have spent half a day trying to figure this out and your solution works perfectly and should be the accepted answer to this question&lt;/P&gt;</description>
    <pubDate>Tue, 21 Mar 2023 15:46:34 GMT</pubDate>
    <dc:creator>RichardHowe</dc:creator>
    <dc:date>2023-03-21T15:46:34Z</dc:date>
    <item>
      <title>Clone Items and setting new Item Extent</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/clone-items-and-setting-new-item-extent/m-p/1087579#M6461</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to clone a Web App but have it centered over a&amp;nbsp; new area (new city for example) and i was wondering if I could use the&amp;nbsp;&lt;SPAN&gt;item_extent parameter from clone_items to achieve this. Anyone have any ideas?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Aug 2021 17:33:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/clone-items-and-setting-new-item-extent/m-p/1087579#M6461</guid>
      <dc:creator>gis_user_ca</dc:creator>
      <dc:date>2021-08-10T17:33:12Z</dc:date>
    </item>
    <item>
      <title>Re: Clone Items and setting new Item Extent</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/clone-items-and-setting-new-item-extent/m-p/1176749#M7423</link>
      <description>&lt;P&gt;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:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;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],
                                        folder=event_name, 
                                        item_extent=ext, 
                                        search_existing_items=False)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;#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
new_item.share(True)

#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_item.update(item_properties={'extent':ex1})

new_item.update(item_properties={'extent':ex2})

new_map = WebMap(copy_item)
new_map.definition['initialState'] = ex&lt;/LI-CODE&gt;&lt;P&gt;If someone could offer some insight on this, that would be amazing!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2022 08:27:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/clone-items-and-setting-new-item-extent/m-p/1176749#M7423</guid>
      <dc:creator>GreeMko_Admin</dc:creator>
      <dc:date>2022-05-24T08:27:41Z</dc:date>
    </item>
    <item>
      <title>Re: Clone Items and setting new Item Extent</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/clone-items-and-setting-new-item-extent/m-p/1248210#M8273</link>
      <description>&lt;P&gt;Hello, I just wrestled with this too.&amp;nbsp; I am copying from a template webmap that has a Field Maps customization, so I wish to have those edit layers- but I then need to change the extent of the webmap to fit different areas of interest.&lt;/P&gt;&lt;P&gt;This works for me:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Get the template webmap item ID
Template_WebMap_Item = gis.content.get('cf6eec40dbd644d99b4645547e2614d5')

# Create a WebMap object from an existing web map item
Template_map_obj = WebMap(Template_WebMap_Item)

# Update the properties for new map
wm_properties = {'title' : 'New Web Map {0}'.format(EventAliasName),
                 'snippet': "Web map for earthquake response data acquisition",
                 'tags' : 'Observations',
                 'type': 'Web Map'
                 }

# Add a layer unique to this event
Template_map_obj.add_layer(ShakeMap_MI_layer)

# Save the webmap to the new Event Folder
TheEventMap = Template_map_obj.save(item_properties = wm_properties, folder=event_folder)

# Get the text data associated with the new webmap item
theEventMap_data = TheEventMap.get_data()

# Examine the 'initialState' key
print(theEventMap_data['initialState'])
# {'viewpoint': {'targetGeometry': {'spatialReference': {'latestWkid': 3857, 'wkid': 102100}, 'xmin': -14142684.7214327, 'ymin': 4011415.2444049953, 'xmax': -12384021.574647833, 'ymax': 5128007.353594553}}}

# Generate a new initialState key using a specific feature layer extent.  Or do this manually
New_Istate =  {'viewpoint': {'targetGeometry': {'spatialReference': {'latestWkid': ShakeMap_MI_layer.properties.extent.spatialReference.latestWkid,
     'wkid': ShakeMap_MI_layer.properties.extent.spatialReference.wkid},
    'xmin': ShakeMap_MI_layer.properties.extent['xmin'],
    'ymin': ShakeMap_MI_layer.properties.extent['ymin'],
    'xmax': ShakeMap_MI_layer.properties.extent['xmax'],
    'ymax': ShakeMap_MI_layer.properties.extent['ymax']}}}


# Update the webmap item 
theEventMap_data['initialState'] = New_Istate
TheEventMap.update(item_properties={"text": json.dumps(theEventMap_data)})&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The new saved webmap now has the desired extent upon loading it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note the last line here.&amp;nbsp; Formatting correctly the 'item_properties' in the update method seems to be critical element here.&amp;nbsp; I learned this &lt;A href="https://community.esri.com/t5/arcgis-api-for-python-questions/item-update-is-breaking-wab-apps/m-p/856622" target="_self"&gt;from this thread&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;Luke&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2023 20:07:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/clone-items-and-setting-new-item-extent/m-p/1248210#M8273</guid>
      <dc:creator>JLBlair</dc:creator>
      <dc:date>2023-01-13T20:07:17Z</dc:date>
    </item>
    <item>
      <title>Re: Clone Items and setting new Item Extent</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/clone-items-and-setting-new-item-extent/m-p/1269894#M8520</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/454604"&gt;@JLBlair&lt;/a&gt;&amp;nbsp;Thank you so much. I have spent half a day trying to figure this out and your solution works perfectly and should be the accepted answer to this question&lt;/P&gt;</description>
      <pubDate>Tue, 21 Mar 2023 15:46:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/clone-items-and-setting-new-item-extent/m-p/1269894#M8520</guid>
      <dc:creator>RichardHowe</dc:creator>
      <dc:date>2023-03-21T15:46:34Z</dc:date>
    </item>
  </channel>
</rss>

