MapControl.ZoomToFit(IEnumerable<MapItem>, Double, Boolean) Method
Zooms the map based on a specified padding factor to allow the map viewport to display all items passed in parameters. Allows you to set whether the map should use a non-negative integer zoom level.
Namespace: DevExpress.XtraMap
Assembly: DevExpress.XtraMap.v24.1.dll
NuGet Package: DevExpress.Win.Map
Declaration
public void ZoomToFit(
IEnumerable<MapItem> items,
double paddingFactor,
bool roundZoomLevel
)
Parameters
Name | Type | Description |
---|---|---|
items | IEnumerable<MapItem> | Items that should be displayed in the map viewport. |
paddingFactor | Double | Specifies the size of the border around displayed map items. |
roundZoomLevel | Boolean | Specifies whether to round the zoom level value. |
Remarks
When vector items are loaded at runtime, the ZoomToFit
method should be called from LayerBase.DataLoaded event handler.
The ZoomToFit
method works as follows:
Calculates a bounding box around items.
Zooms the map to fit the box. Note that the padding factor is applied to the larger dimension of the box.
The following image shows an instance of a horizontal dimension that is larger than the vertical (“PF” means “Padding Factor” on images).
When the vertical dimension is larger than the horizontal, the zoom appears as follows:
Note that the padding factor is divided by two for each side of the region.
Example
The following code zooms the map to display specified items:
using DevExpress.XtraMap;
private void OnVectorLayerDataLoaded(object sender, DataLoadedEventArgs e) {
mapControl1.ZoomToFit(items: storage.Items, roundZoomLevel: true, paddingFactor: 0.3);
}