我从这个网站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);
}