缩放到图层,缩放到要素

public static void ZoomToLayer(IActiveView pActiveView, ILayer pLayer,double pading)
{
pActiveView.Extent = ((IGeoDataset)pLayer).Extent;
pActiveView.Extent.Width += pading;
pActiveView.Extent.Height += pading;
pActiveView.Refresh();
}

public static void ZoomToFeature(IFeature pFeature, int bufferDistant)
{
IGeometry tGeometry = pFeature.Shape as IGeometry; //缓冲处理,使处于边界的元素在视图中能够完全显示
ITopologicalOperator mTopologicalOperator = (ITopologicalOperator)tGeometry;
IGeometry mPolygonBuffer = mTopologicalOperator.Buffer(bufferDistant) as IGeometry;
//MapControl.Extent = mPolygonBuffer.Envelope;
//MapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, featureSelection, tGeometry.Envelope);
//ArcMap.Document.ActiveView.Extent = axMapControl1.ActiveView.Extent;
// ArcMap.Document.ActiveView.Refresh();
ArcMap.Document.ActiveView.Extent = mPolygonBuffer.Envelope;
ArcMap.Document.ActiveView.Refresh();
}

posted @ 2022-03-28 11:48  南山种豆8  阅读(76)  评论(0)    收藏  举报