I have a seemingly simple requirement that is causing me all types of headaches - listening for a map click event in ArcMap via ArcObjects. Simple as that, just tell me when the map is clicked (and x,y location obviously).

After some research, it appears that creating a custom tool that implements ITool was the way to go. Well it turns out that approach gets ugly due to some 'bugs' in ArcGIS Desktop (v10 at least). I don't want to add my custom tool to a toolbar, as it doesn't do anything and is irrelevant for a traditional ArcMap user. So, I thought I would just create a 'hidden' toolbar containing my custom tool. Well it turns out hiding a toolbar doesn't work so well (see Activating custom ITool from form without adding it to ArcMap AddIn toolbar?).

The only other thing I can think of to do is add my custom tool to a 'standard' toolbar. The problem with this approach is that if the user then hides or removes whatever standard toolbar I put the custom tool in from ArcMap, the tool is no longer accessible.

Can someone tell me how to listen for a map click event without all the aforementioned complications?

  • If you want to listen out for map events in arcmap I think the way to do it is to create an extension and use that to get a handle on the events. – Hornbydd Apr 15 '12 at 22:44
  • Did you get a solution to your problem? – ujjwalesri Jun 6 '14 at 7:33

For me in 9.3.1, this is working. Registering to the appropriate event...

((ESRI.ArcGIS.Controls.AxMapControl)PlanetBase.MapControlComponent).OnMouseDown += new ESRI.ArcGIS.Controls.IMapControlEvents2_Ax_OnMouseDownEventHandler(Class1_OnMouseDown);

...and going on with...

void Class1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)

I just checked, it works in ESRI 10 also...

  • Looks like your code is for ArcEngine; I am looking for ArcMap equivalent. – user890 Mar 25 '12 at 15:50

Not the answer you're looking for? Browse other questions tagged or ask your own question.