ThinkGeo.com    |     Documentation    |     Premium Support

Bounding box seems to be too large

Hello! I’m doing some simple “zooming” to a layer’s bounding box. However, it seems like there is always some extra space around the extent.

For example, let’s say I have a single line feature in an InMemoryFeatureLayer (layer is named sampleLayer). To zoom to that layer, I do:

sampleLayer.Open();
myMap.CurrentExtent = sampleLayer.GetBoundingBox();
myMap.Refresh());

Afterwards, the map looks like:

So it did zoom in, but I was expecting it to zoom to the point where the ends of the line are at the edge of the map. Is there a certain setting to do this? Or does it have to do with zoom levels?

Hi Dan,

The behavior you see is the expected default. There are 20 zoom levels by default and when you set the CurrentExtent of the map to the layer’s bounding box, the map will choose the highest zoomlevel that fits the entire shape. If the map were to zoom in one more level, then the line would not fully show.

You should be able to control this using the ZoomLevelSnappingMode property on the mapView. You should be able to set this property to ZoomLevelSnappingMode.None.

Thanks,
John

1 Like

Thank you! That seems to do the trick.

Great! Good luck and let us know if you have other questions.

Thanks,
John