AxMap.ZoomToSelected sometimes zooms more than needed

Jun 25, 2015 at 3:47 PM
Hi every one,

I implements a service that use AxMap.ZoomToSelected(), but some times the new extents (after zooming) is smaller (in surface) than that for selected features. I notice that while selecting two point features and doing ZoomToSelected(): after zooming, the selected points are outside the new extents.

Is there any idea to solve that?
Developer
Jun 28, 2015 at 9:43 AM
HI, most likely it's caused by AxMap.ZoomBehavior = zbUseTileLevels, which is set by default. It adjusts extents to the closest tile level. In theory it can only expand the extents, but apparently we have a bug there (those calculations are quite tricky).

To solve this you can:
a) call AxMap.ZoomOut() after zooming (optionally call AxMap.LockWindow to make it look like a single zoom);
b) set AxMap.ZoomBehavior = zbDefault and add more padding after zooming by expanding AxMap.Extents;
var ext = AxMap.Extents;
ext.GetBounds(...);
var extNew = new Extents();
extNew.SetBounds(...);   // larger extents
axMap1.Extents = extNew;
c) calculate extents of selected shapes yourself and add enough padding.

Unfortunately AxMap.ZoomToSelected doesn't use AxMap.ExtentPad property - it would be easier to handle it that way, I'll add its support in the next release.

Regards,
Sergei
Jun 29, 2015 at 7:39 AM
Thank you very much Sergei.
My best regards