Select to view content in your preferred language

How to capture the coordinates on a map on mouse click.

3356
4
06-18-2021 08:06 AM
TapasChakrabarty
Emerging Contributor

Hi,

 I have an Add-In screen on which I have a Record button. Now my requirement is:

When I click on the record button it will take me to the map and I should be able to capture the values of X/Y coordinates on the mouse left click on the map.

Can anyone help me to achieve this purpose?

 

I am using ArcGIS Pro 2.8 SDK, VS2019.

0 Kudos
4 Replies
Wolf
by Esri Regular Contributor
Esri Regular Contributor

You can look at this example: arcgis-pro-sdk-community-samples/Map-Exploration/MapToolWithOverlayControl at master · Esri/arcgis-p...

this shows the coordinates for a mouse click in an overlay control.

0 Kudos
TapasChakrabarty
Emerging Contributor

Agreed @Wolf, I have gone through the example but I have doubts about how to call the mouse click from the Add-In page button click.

0 Kudos
Wolf
by Esri Regular Contributor
Esri Regular Contributor

I am not sure what you mean, but the way to implement an interactive 'mouse click' on a map view is by implementing an 'ArcGIS Pro Map Tool' in your add-in by using the 'ArcGIS Pro Map Tool' item template:

Wolf_0-1624031758101.png

 

Once you have implemented this and copied the relevant mouse click code from the community sample i mentioned above, you can use the map tool's button on the ArcGIS Pro ribbon tab.  If you want to use that same 'mouse click' tool from anywhere in your code or from a button on a dockpane you can use the Pro Guide for 're-using Pro Commands' to implement this functionality:  ProGuide Reusing Pro Commands · Esri/arcgis-pro-sdk Wiki (github.com)

 

0 Kudos
TapasChakrabarty
Emerging Contributor

Hi, @Wolf MapTool create a seperate Add-In tool. But I don't mean to add another button to my Add-In. Let me explain my requirement point-wise.

1. I have Add-In in which there is an add-in button that opens a page.

2. On that page I have a Record button (c# wpf button).

3. When I click on that Record button, my Add-in page is minimized, and I can click on the map.

Now I want to capture the coordinates on the map where ever I left click.

The example u gave adds an overlay page on the map but the source to open the page is from the add-in where another tool button gets added.

0 Kudos