The extent is the property of a data frame, not the map.
Unfortunately it appears there is no Zoom To Full Extent method documented in the help for DataFrame, and, furthermore, the property of full extent is not exposed in a property either. Looks like you need to go to .NET to get at this property.
DataFrame—Help | ArcGIS Desktop
The equivalent object to get at map extents in Pro, the Camera object, also has no such method or property.
Maybe something to ask for in ideas?
From the DataFrame—Help | ArcGIS Desktop documention:
zoomToSelectedFeatures ()This performs the same ArcMap operation as Selection > Zoom To Selected Features. One difference is that if no features are selected, it will zoom to the full extent of all layers. If you want to zoom to the extent of selected features for a specific layer, try using the Layer.getSelectedExtent method.
Cool, nice catch Joshua Bixby. It should be noted that the world button does this behavior by default only if you haven't modified it by setting the data frame full extent to something besides the extent of all features.
And, the tricky part is nothing can be selected, so I wouldn't say it is exactly what the OP wants but close. I was thinking last night that a function could be created that would loop through all of the layers in the active data frame and find the extent needed to display them all. It wouldn't be that hard to write, I just need to find some time to sit down and tinker.
Absolutely, you'd do this with the arcpy geometry objects extent property.
Note I found the DataFrame ("Map") AreaOfInterest property in ArcObjects and it is only writeable, not readable. How about that.
I got the following custom function to work for me in the interactive Python window:
def zoomToFullExtent(map_document):
DF = map_document.activeDataFrame
DF_extent = DF.extent
for lyr in arcpy.mapping.ListLayers(map_document, data_frame=DF):
extent = lyr.getExtent()
DF_extent.XMin = min(DF_extent.XMin, extent.XMin)
DF_extent.XMax = max(DF_extent.XMax, extent.XMax)
DF_extent.YMin = min(DF_extent.YMin, extent.YMin)
DF_extent.YMax = max(DF_extent.YMax, extent.YMax)
DF.extent = DF_extent
I like your method better than geometry objects. Here's a little function that may be handy in other contexts too.
# neat function
def FullExtent(extent_list):
"full extent from list of extents"
return arcpy.Extent(min([e.XMin for e in extent_list]),
min([e.YMin for e in extent_list]),
max([e.XMax for e in extent_list]),
max([e.YMax for e in extent_list]))
mxd = arcpy.mapping.MapDocument("CURRENT")
df = mxd.activeDataFrame
exts = [lyr.getExtent() for lyr in arcpy.mapping.ListLayers(mxd, "*", df)]
df.extent = FullExtent(exts)
arcpy.RefreshActiveView()