如题,不更改当前比例尺,把指定点Zoom到地图中心。
![](https://img.laitimes.com/img/9ZDMuAjOiMmIsIjOiQnIsIiZpdmLlR2bjlHcvN2LcNXZnFWbp9CXt92YuM3ZvxmYuNmLu9Wbt92Yvw1LcpDc0RHaiojIsJye.gif)
Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
[CommandMethod("ZoomCenter")]
public void ZoomCenter()
{
AcMapMap map = AcMapMap.GetCurrentMap();
MgEnvelope mapExtent = map.GetMapExtent();
double centerX = mapExtent.LowerLeftCoordinate.X + mapExtent.Width / 2;
double centerY = mapExtent.LowerLeftCoordinate.Y + mapExtent.Height / 2;
ed.WriteMessage("center:"+centerX.ToString()+","+centerY.ToString()+"\n");
Point3d centerPt;
PromptPointOptions ppo = new PromptPointOptions("Click on map to zoom center:");
PromptPointResult ppr = ed.GetPoint(ppo);
if (ppr.Status == PromptStatus.OK)
{
centerPt = ppr.Value;
MgEnvelope newExtent = new MgEnvelope(centerPt.X - mapExtent.Width / 2,
centerPt.Y - mapExtent.Height / 2,
centerPt.X + mapExtent.Width / 2,
centerPt.Y + mapExtent.Height / 2);
map.ZoomToExtent(newExtent);
}
}
![](https://img.laitimes.com/img/9ZDMuAjOiMmIsIjOiQnIsIiZpdmLlR2bjlHcvN2LcNXZnFWbp9CXt92YuM3ZvxmYuNmLu9Wbt92Yvw1LcpDc0RHaiojIsJye.gif)
转载请保留此信息。
本文转自峻祁连. Moving to Cloud/Mobile博客园博客,原文链接:http://www.cnblogs.com/junqilian/archive/2011/10/12/2208849.html,如需转载请自行联系原作者