zoukankan      html  css  js  c++  java
  • Map3D中获取地图中心及Zoom到新的中心点

    如题,不更改当前比例尺,把指定点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);
                }

            }
    作者:峻祁连
    邮箱:junqilian@163.com
    出处:http://junqilian.cnblogs.com
    转载请保留此信息。
  • 相关阅读:
    Leetcode: Palindrome Permutation
    Leetcode: Ugly Number
    Leetcode: Ugly Number II
    Leetcode: Single Number III
    Leetcode: 3Sum Smaller
    Leetcode: Factor Combinations
    Leetcode: Different Ways to Add Parentheses
    Leetcode: Add Digits
    GigE IP地址配置
    Ubuntu 关闭触摸板
  • 原文地址:https://www.cnblogs.com/junqilian/p/2208849.html
Copyright © 2011-2022 走看看