天天看点

Map3D中获取地图中心及Zoom到新的中心点

如题,不更改当前比例尺,把指定点Zoom到地图中心。

Map3D中获取地图中心及Zoom到新的中心点

        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);

            }

        }

Map3D中获取地图中心及Zoom到新的中心点

邮箱:[email protected] 

转载请保留此信息。

本文转自峻祁连. Moving to Cloud/Mobile博客园博客,原文链接:http://www.cnblogs.com/junqilian/archive/2011/10/12/2208849.html,如需转载请自行联系原作者

继续阅读