1

我从这个网站http://forums.arcgis.com/threads/30635-How-to-Select-Feature-by-XY-Location-and-Highlight-it-in-ArcMap-9.3-programmatically借用了这段代码

它涉及缩放到地图点。但我不知道如何实现这一点。或者我需要或使用的参考资料。

因为我是 arcgis 和 c# 的菜鸟。如果有更多经验的人可以帮助我,将不胜感激。

public static void CaptureMapCoordinates(int x, int y)
    {
        // get the map coordinates from the screen coordinates
        IPoint pScreenPoint = new ESRI.ArcGIS.Geometry.Point();
        IPoint pMapPoint = new ESRI.ArcGIS.Geometry.Point();
        IEnvelope pEnv = new EnvelopeClass();

        pScreenPoint.X = x;
        pScreenPoint.Y = y;

        pMapPoint = GetMapCoordinatesFromScreenCoordinates(pScreenPoint, pActiveView);

        pEnv = pActiveView.Extent;
        pEnv.CenterAt(pMapPoint);

        pActiveView.Extent = pEnv;
        pActiveView.Refresh();

    }

    private static IPoint GetMapCoordinatesFromScreenCoordinates(IPoint pScreenPoint, IActiveView pActiveView)
    {
        IScreenDisplay pScreenDisplay;
        IDisplayTransformation pDisplayTransformation;

        if (pScreenPoint == null || pScreenPoint.IsEmpty || pActiveView == null)
        {
            return null;
        }

        pScreenDisplay = pActiveView.ScreenDisplay;
        pDisplayTransformation = pScreenDisplay.DisplayTransformation;

        return pDisplayTransformation.ToMapPoint((int)pScreenPoint.X, (int)pScreenPoint.Y);
    }
4

1 回答 1

0

我从您的评论中得知您希望添加 ArcMap 而不是独立的 WPF 应用程序。我相信这个链接会让你开始。这是为 ArcMap 创建插件的分步过程

http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/Walkthrough_Building_custom_UI_elements_using_add_ins/0001000001ms000000/

您将需要 Visual Studio 进行开发。

如果对您有帮助,请将其标记为答案。谢谢

于 2013-10-23T13:43:14.930 回答