天天看點

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,如需轉載請自行聯系原作者

繼續閱讀