I am trying to get information from fields within specific feature classes based on an XY point. The user will click on the add-in tool, click on a location in ArcMap, and the tool will find the information from about 5 different feature classes. This information will be taken and sent to a windows form for the user to see. I already have code to get the XY click in both screen and map coordinates but don't know how to go about getting the field information. If I could get 5 strings back to send to the form, that would be perfect. Any help and insight would be great. Also, feel free to improve my existing code.
Here is what I have so far:
namespace LocationResources { public class LocationIdentify : ESRI.ArcGIS.Desktop.AddIns.Tool { //Define and initialize global variables private string director = ""; private string city = ""; private string county = ""; private string school = ""; private string subdivision = ""; private IPoint screenPoint; private IPoint mapPoint; public LocationIdentify() { } protected override void OnUpdate() { Enabled = ArcMap.Application != null; } protected override void OnMouseDown(MouseEventArgs arg) { if (arg.Button == System.Windows.Forms.MouseButtons.Left) { try { // Get mouse click location in pixels (screen coordinates) screenPoint = new Point(); screenPoint.X = arg.X; screenPoint.Y = arg.Y; // Get map document information for transforming pixels to feet coordinates IApplication m_application = Hook as IApplication; IScreenDisplay screenDisplay = (m_application.Document as IMxDocument).ActiveView.ScreenDisplay; // Transform mouse click location into feet (map coordinates) mapPoint = screenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y); } catch { MessageBox.Show("Something went wrong getting the XY point."); } try { // Get spatial information GetSpatialInformation(screenPoint); // If screenPoint works mapPoint may not be needed } catch { MessageBox.Show("Something went wrong getting the spatial information"); } // Launch location information form LocationInformation info = new LocationInformation(director, city, county, school, subdivision); info.Show(); } } private void GetSpatialInformation(IPoint coordinates) { // TO-DO --> Get spatial information } } }
أكثر...
Here is what I have so far:
namespace LocationResources { public class LocationIdentify : ESRI.ArcGIS.Desktop.AddIns.Tool { //Define and initialize global variables private string director = ""; private string city = ""; private string county = ""; private string school = ""; private string subdivision = ""; private IPoint screenPoint; private IPoint mapPoint; public LocationIdentify() { } protected override void OnUpdate() { Enabled = ArcMap.Application != null; } protected override void OnMouseDown(MouseEventArgs arg) { if (arg.Button == System.Windows.Forms.MouseButtons.Left) { try { // Get mouse click location in pixels (screen coordinates) screenPoint = new Point(); screenPoint.X = arg.X; screenPoint.Y = arg.Y; // Get map document information for transforming pixels to feet coordinates IApplication m_application = Hook as IApplication; IScreenDisplay screenDisplay = (m_application.Document as IMxDocument).ActiveView.ScreenDisplay; // Transform mouse click location into feet (map coordinates) mapPoint = screenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y); } catch { MessageBox.Show("Something went wrong getting the XY point."); } try { // Get spatial information GetSpatialInformation(screenPoint); // If screenPoint works mapPoint may not be needed } catch { MessageBox.Show("Something went wrong getting the spatial information"); } // Launch location information form LocationInformation info = new LocationInformation(director, city, county, school, subdivision); info.Show(); } } private void GetSpatialInformation(IPoint coordinates) { // TO-DO --> Get spatial information } } }
أكثر...