Zoom to selected feature(s)


/ Published in: C#
Save to your folder(s)

Here is the sample code you can use to zoom to selected features. Please replace m_hookHelper with valid mapcontrol object.


Copy this code and paste it in your HTML
  1. public void ZoomToSelectedFeatures()
  2. {
  3. ESRI.ArcGIS.Carto.IActiveView pActiveView;
  4. ESRI.ArcGIS.Carto.IMap pMap;
  5. ESRI.ArcGIS.Geodatabase.IEnumFeature pEnumFeature;
  6. ESRI.ArcGIS.Geodatabase.IFeature pFeature;
  7.  
  8. pMap = (IMap)m_hookHelper.FocusMap;
  9. pEnumFeature = (IEnumFeature)pMap.FeatureSelection;
  10. pFeature = pEnumFeature.Next();
  11.  
  12. ESRI.ArcGIS.Geometry.IEnvelope pEnvelope;
  13. pEnvelope = new EnvelopeClass();
  14.  
  15. while (pFeature != null)
  16. {
  17. pEnvelope.Union(pFeature.Shape.Envelope);
  18. pFeature = pEnumFeature.Next();
  19. }
  20.  
  21. pEnvelope.Expand(1.2, 1.2, true);
  22. pActiveView = m_hookHelper.ActiveView;
  23. pActiveView.Extent = pEnvelope;
  24. pActiveView.Refresh();
  25. }

URL: http://forums.esri.com/Thread.asp?c=159&f=1707&t=233785

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.