0

I have an axMapControl in a WinForms application. According to the ArcGIS documentation,

[The]OnExtentUpdated [event] is triggered whenever the IMapControl2::Extent property is changed. Setting the extent explicitly, zooming, panning or using the IMapControl2::CenterAt method will change the extent.

But how can I know (programmatically) inside the event handler that it was zooming or panning that caused the extent to change? I am looking for some C# code which would enable me to know that the extent change was caused by one of those two things.

1 Answers1

1

The second argument of this event handler (sizeChanged) checks whether the size of the extent is changed.

IMapControlEvents2.OnExtentUpdated (
  IDisplayTransformation displayTransformation,
  bool sizeChanged,
  IEnvelope newEnvelope
);

if the sizeChanged is true, then a zoom is happened, else its a pan!

Farid Cheraghi
  • 8,773
  • 1
  • 23
  • 53
  • Thank you! Is there a way to know in the event handler that the extent change was caused by neither the zoom nor the pan? For example if the extent was explicitly set in code? – EleventhDoctor May 14 '15 at 09:35
  • I don't think that is possible with this event listener. In fact, when a zoom/pan happens, in the code behind the extent is changed. So either ways the extent is changed within the code. – Farid Cheraghi May 14 '15 at 10:29
  • To distinct between users zoom/pan and extent change using coding, you should check for the active tool in the event listener. If the active tool is pan/zoom then it is a pan and zoom. – Farid Cheraghi May 14 '15 at 10:33
  • Sounds good - do you think you could provide a code example in your answer to make it really clear? – EleventhDoctor May 18 '15 at 11:39