ArcGIS Pro 3.2 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / Layer Class / QueryExtent Method
(Optional) -true- computes extent of the layer using largest symbol size.
-false- returns the underlying FeatureClass' full extent.
(default value = false)
Example

In This Topic
    QueryExtent Method
    In This Topic
    Returns extent of the layer optionally taking symbol size in account. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public Envelope QueryExtent( 
       bool includeSymbolSize
    )
    Public Function QueryExtent( _
       Optional ByVal includeSymbolSize As Boolean _
    ) As Envelope

    Parameters

    includeSymbolSize
    (Optional) -true- computes extent of the layer using largest symbol size.
    -false- returns the underlying FeatureClass' full extent.
    (default value = false)

    Return Value

    An envelope that covers all features of the layer.
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Remarks
    If you want to get extent to zoom to the layer's extent but do not want to see features cut off on edges, you should use
    Example
    MapFrame_SetCamera_Envelope
    //Set the extent of a map frame to the envelope of a feature.
    
    //Perform on the worker thread
    await QueuedTask.Run(() =>
    {
      //Reference MapFrame
      MapFrame mf_env = layout.FindElement("Map Frame") as MapFrame;
    
      //Get map and a layer of interest
      Map m = mf_env.Map;
      //Get the specific layer you want from the map and its extent
      FeatureLayer lyr = m.FindLayers("GreatLakes").First() as FeatureLayer;
      Envelope lyrEnv = lyr.QueryExtent();
    
      //Set the map frame extent to the feature layer's extent / envelope
      mf_env.SetCamera(lyrEnv);  //Note - you could have also used the lyr as an overload option
    });
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also