AnsweredAssumed Answered

[ArcEngine] Prevent ArcObjects from changing the view extent when adding a map layer

Question asked by Adjutant on Apr 13, 2012
Latest reply on Jul 13, 2012 by Adjutant
Greetings,

The custom application I am using relies on the OnExtentUpdated() event, which is called by ArcObjects whenever the map extent is updated.
There seems no way to specify that this callback should only be triggered from actual user actions (i.e. pan and zoom) - and NOT when adding a map layer.

A simple workaround would be to simply set a flag when adding a map layer and consequently not to handle the update event when it is triggered - but this has it's drawbacks :
1) I cannot guarantee that the flag will not accidentally ignore a user operation (for instance if a map is being added at the same time during runtime).
2) More importantly, map objects still sets the Extent object itself - which would require me to override the extent again - but that in turn would trigger the ExtentUpdated callback. Far too messy.

The only alternative I can see at the moment : Ignore the ExtentUpdated event completely, manually intercept all user pan and zoom operations, and keep track of the map extent explicitly (i.e. ignore the ArcObjects extent, and only set it when it is required to set the extent programmatically).
Please tell me there is a better way to gain more control over the map extent?

Thanks.

Outcomes