フィルター設定が適用されたレイヤーの全体表示

'引数   :IFeatureLayerDefinition  選択したフィーチャから作成したレイヤ
'戻り値 :IEnvelope                フィルタ設定によって絞り込まれたレイヤ範囲
Public Function ExtentFromDefinitionExpression(FeatureLayer As IFeatureLayerDefinition) As IEnvelope
    
    Dim pFeatureLayer As IFeatureLayer
    Set pFeatureLayer = FeatureLayer
    
    Dim pQueryFilter As IQueryFilter
    Set pQueryFilter = New QueryFilter
    pQueryFilter.WhereClause = FeatureLayer.DefinitionExpression
        
    Dim pEnumGeometryBind As IEnumGeometryBind
    Set pEnumGeometryBind = New EnumFeatureGeometry
    
    pEnumGeometryBind.BindGeometrySource pQueryFilter, pFeatureLayer.FeatureClass
    
    Dim pGeometryFactory As IGeometryFactory
    Set pGeometryFactory = New GeometryEnvironment
    
    Dim pGeometry As IGeometry
    Set pGeometry = pGeometryFactory.CreateGeometryFromEnumerator(pEnumGeometryBind)
    
    Set ExtentFromDefinitionExpression = pGeometry.Envelope

End Function