Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 2 down vote accepted

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.

share|improve this answer
Thanks artwork21. Thats the trick. See my answer for implementation details. – gumo Oct 20 '11 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;
share|improve this answer
Won't the envelope be larger than what is visible if IDisplayTransformation.Rotation is not zero? – Kirk Kuykendall Apr 3 '13 at 14:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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