2013-10-23 48 views
1

我从本网站 http://forums.arcgis.com/threads/30635-How-to-Select-Feature-by-XY-Location-and-Highlight-it-in-ArcMap-9.3-programmaticallyArcGIS中使用的参考

它涉及缩放到一个MapPoint借用了这个代码。 但我不知道如何实现这一点。 或至少需要或使用的引用。

因为我在arcgis和c#总noob。 如果有更多经验的人可以帮助我 它将不胜感激。

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); 
    } 
+0

你想达到什么目的?要在WPF应用程序中将要素图层添加到底图中,然后在点击/单击要素图层的要素时,是否要将该位置放大?你已经完成底图部分和要素图层部分了吗?您是否已经使用ESRI API参考创建了一个WPF应用程序? – azmuhak

+0

@azmuhak我想放大zo坐标(如果可以在可停靠的窗口中通过事件)我只需要给它坐标,它就会去那里。 – Robin

+0

明白了。你还可以在上面的评论中回答我的其他问题吗? – azmuhak

回答

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的发展一步步的过程。

请标记为答案,如果它帮助你。 谢谢

+0

你得到了正确的部分。 但是,这并没有帮助我使我需要的变焦。 如果你知道任何关于它,将不胜感激。 – Robin

+0

你得到的代码是可以的。但是在代码之前和之后缺少很多东西。我正在讨论项目设置和添加服务引用,并编写标记文件和最终将添加这两种方法的c#类。这就是为什么我分享了该链接以帮助您开始使用该链接的基本插件,然后尝试将这些功能添加到该基本项目中。如果此时出现任何问题,请将其发布到此处,我们将看到如何解决该问题。 – azmuhak