I like to add text information to each feature in the shown map extent in my MapControl/PageLayoutControl. Adding the text is not a problem, but I couldn't find a way on how to get the features.

Is there a way to get all features in a layer that are in the current map extent?

2 Answers 2


Have you looked at:

Dim pEnv As IEnvelope
 pEnv = pAv.ScreenDisplay.DisplayTransformation.VisibleBounds

Setting the envelope = to the activeview visible bounds. You will then have to define a spatial filter, find the specific feature class, and set that to a featurecursor to grab all the features.

  • Thanks artwork21. Thats the trick. See my answer for implementation details.
    – gumo
    Commented Oct 20, 2011 at 13:17

Thanks to artwork21 I could solve this like this:

IMap map = this._mapControl.ActiveView.FocusMap;
IEnvelope envelope = _mapControl.ActiveView.ScreenDisplay.DisplayTransformation.VisibleBounds;

IGeoFeatureLayer featLayer = myLayer as IGeoFeatureLayer;
if (featLayer != null)
IFeatureClass featureClass = featLayer.FeatureClass;
System.String shapeFieldName = featureClass.ShapeFieldName;
// Create a new spatial filter and use the new envelope as the geometry
ISpatialFilter spatialFilter = new SpatialFilterClass();
spatialFilter.Geometry = envelope;
spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelEnvelopeIntersects;
spatialFilter.set_OutputSpatialReference(shapeFieldName, map.SpatialReference);
spatialFilter.GeometryField = shapeFieldName;

// Do the search
IFeatureCursor featureCursor = featureClass.Search(spatialFilter, false);
return featureCursor;
  • 1
    Won't the envelope be larger than what is visible if IDisplayTransformation.Rotation is not zero? Commented Apr 3, 2013 at 14:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.