Problem: Inserting a point of data in a map produces inaccurate results
【相关信息】
Article ID: 42325
Bug Id: N/A
Software:
ArcGIS - ArcEditor 10
ArcGIS - ArcInfo 10
ArcGIS - ArcView 10
Platforms:
Windows Windows 7
【问题描述】
When adding a point feature to a map in ArcGIS Desktop 10 by clicking in the map using an add-in tool or a COM component base tool, the coordinates of the newly created point are incorrect.
【原因】
The coordinates are incorrect because they are currently screen coordinates, and not map coordinates.
Article ID: 42325
Bug Id: N/A
Software:
ArcGIS - ArcEditor 10
ArcGIS - ArcInfo 10
ArcGIS - ArcView 10
Platforms:
Windows Windows 7
【问题描述】
When adding a point feature to a map in ArcGIS Desktop 10 by clicking in the map using an add-in tool or a COM component base tool, the coordinates of the newly created point are incorrect.
【原因】
The coordinates are incorrect because they are currently screen coordinates, and not map coordinates.
1 个回复
EsriSupport
赞同来自:
Convert the X and Y onMouseDown event arguments from screen coordinates to map coordinates using IDisplayTransformation::ToMapPoint(). The map coordinates use the coordinate system of the newly created feature’s feature class.
Below is a code sample based on the following link:
ArcObjects Help for .NET
/// The code herein is based on the Add-In sample at this link on ESRI's Resources Website:
/// http://resources.arcgis.com/en ... 00000
///
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using ESRI.ArcGIS.ArcMapUI;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Display;
using ESRI.ArcGIS.Geometry;
namespace AddIn_OnMouseDown_Tool
{
public class Class_OnMouseDown_Tool : ESRI.ArcGIS.Desktop.AddIns.Tool
{
// Module level variables
private IActiveView m_focusMap;
public Class_OnMouseDown_Tool()
{
}
protected override void OnUpdate()
{
Enabled = ArcMap.Application != null;
}
protected override void OnMouseDown(MouseEventArgs arg)
{
IMxDocument mxDoc = ArcMap.Document;
m_focusMap = mxDoc.FocusMap as IActiveView;
IPoint point = m_focusMap.ScreenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y) as IPoint;
System.Windows.Forms.MessageBox.Show(
"point.X = " + point.X + "\n" +
"point.Y = " + point.Y + "\n"
);
}
}
}
Related Information
Created: 3/14/2014 Last Modified: 10/23/2014
【原文链接】
http://support.esri.com/en/kno ... 42325
要回复问题请先登录或注册