I am working with the ArcGIS API for Python mapping widget within the ArcGIS jupyter notebook environment. I've successfully connected to my organization's enterprise portal, grabbed content, mapped it, and set the zoom level manually (see code below). The problem is when I try to zoom to the added layer, at which point I receive the error:
AttributeError: 'MapView' object has no attribute 'zoom_to_layer'
According to the arcgis.widgets documentation page and all other Esri tutorials I've seen zoom_to_layer() exists and I'm using the correct syntax, of "map.zoom_to_layer(layer)".
The only thing I can think of is that since my installation of the API is what comes with ArcGIS 10.7.1 (API version 1.6.1) whereas all the online API documentation pages are for version 1.8.2. Is zoom_to_layer() functionality that has been implemented between those two versions? Or can anyone else think of reasons why this might be erroring?
gis = GIS("portal_url", username="my_username")
contentItem = gis.content.get('content_string')
contentLayer = contentItem.layers[0]
m = gis.map()
m.add_layer(contentLayer)
m.zoom_to_layer(contentLayer) #this errors
# m.zoom = 14 #this works fine
m