The solution for New Map Viewer Set Default Extent put me on the right track when I ran into this same issue.
With the new Map Viewer also comes a new way of defining the initial or home view of your web map, the viewpoint. So now you need to set the viewpoint parameter in the item's data, rather than its extent in item_properties.
In your example, you can use get_data to view your item's current viewpoint, e.g.,
wm_item.get_data()
{
'operationalLayers': [],
'baseMap': {
'baseMapLayers': [{
'id': 'World_Hillshade_3805',
'opacity': 1,
'title': 'World Hillshade',
'url': 'https://services.arcgisonline.com/arcgis/rest/services/Elevation/World_Hillshade/MapServer',
'visibility': True,
'layerType': 'ArcGISTiledMapServiceLayer'
},
{
'id': 'VectorTile_2333',
'opacity': 1,
'title': 'World Topographic Map',
'visibility': True,
'layerType': 'VectorTileLayer',
'styleUrl': 'https://cdn.arcgis.com/sharing/rest/content/items/7dc6cea0b1764a1f9af2e679f642f0f5/resources/styles/root.json'
}],
'title': 'Topographic'
},
'authoringApp': 'ArcGISMapViewer',
'authoringAppVersion': '2023.2',
'initialState': {
'viewpoint': {
'targetGeometry': {
'spatialReference': {
'latestWkid': 3857,
'wkid': 102100
},
'xmin': -9363110.186797503,
'ymin': 5143763.742527973,
'xmax': -9274213.922901962,
'ymax': 5258113.536842443
}
}
},
'spatialReference': {
'latestWkid': 3857,
'wkid': 102100
},
'timeZone': 'system',
'version': '2.29'
}
You can store the item's data in a dictionary, then modify the targetGeometry, e.g.,
data_dict = wm_item.get_data()
data_dict['initialState']['viewpoint']['targetGeometry']['xmin'] = -11363110.186797503
data_dict['initialState']['viewpoint']['targetGeometry']['ymin'] = 5143763.742527973
data_dict['initialState']['viewpoint']['targetGeometry']['xmax'] = -11274213.922901962
data_dict['initialState']['viewpoint']['targetGeometry']['ymax'] = 5258113.536842443
Then use update to save your new viewpoint, updating the item's data, rather than its item_properties, e.g.,
web_map_item.update(
data = data_dict
)
You might still want to set the extent property for the web map, as it is supposedly still used in searching/filtering items by location. I usually set both the viewpoint and extent now.