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

451
2
Jump to solution
04-13-2012 08:32 AM
ManfredLauterbach
Occasional Contributor
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.
0 Kudos
1 Solution

Accepted Solutions
ManfredLauterbach
Occasional Contributor
There seems to be no other way to avoid this problem.

As an undesirable alternative, one can also maintain one's own extent history.
Every time OnExtentUpdated is called, check whether the extent has really changed. If the extent coordinates have not changed (i.e. when a layer is added), then ignore the event.

View solution in original post

0 Kudos
2 Replies
ManfredLauterbach
Occasional Contributor
Still can't find a solution for this one - even if we detect that the extent was changed, it still causes serious display issues to refresh twice (set the extent back to what it was) when there are large amounts of data involved.

Please tell me there is a way to prevent arc objects from changing the extent when layers are added?
0 Kudos
ManfredLauterbach
Occasional Contributor
There seems to be no other way to avoid this problem.

As an undesirable alternative, one can also maintain one's own extent history.
Every time OnExtentUpdated is called, check whether the extent has really changed. If the extent coordinates have not changed (i.e. when a layer is added), then ignore the event.
0 Kudos