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 Answer 1

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!

4
  • 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? Commented May 14, 2015 at 9: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. Commented May 14, 2015 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. Commented May 14, 2015 at 10:33
  • Sounds good - do you think you could provide a code example in your answer to make it really clear? Commented May 18, 2015 at 11:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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