AxMap.ZoomToSelected sometimes zooms more than needed

Jun 25, 2015 at 4: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?
Jun 28, 2015 at 10: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;
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.

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