///<summary>Zooms to the selected layer in the TOC associated with the active view.</summary> /// ///<param name="mxDocument">An IMxDocument interface</param> /// ///<remarks></remarks> public void ZoomToActiveLayerInTOC(ESRI.ArcGIS.ArcMapUI.IMxDocument mxDocument) { if(mxDocument == null) { return; } ESRI.ArcGIS.Carto.IActiveView activeView = mxDocument.ActiveView; // Get the TOC ESRI.ArcGIS.ArcMapUI.IContentsView IContentsView = mxDocument.CurrentContentsView; // Get the selected layer System.Object selectedItem = IContentsView.SelectedItem; if (!(selectedItem is ESRI.ArcGIS.Carto.ILayer)) { return; } ESRI.ArcGIS.Carto.ILayer layer = selectedItem as ESRI.ArcGIS.Carto.ILayer; // Zoom to the extent of the layer and refresh the map activeView.Extent = layer.AreaOfInterest; activeView.Refresh(); }
缩放到TOC中的活动图层
最新推荐文章于 2022-06-05 15:18:20 发布