windowsforms-devexpress-dot-xtramap-dot-mapcontrol-dot-zoomtofit-x28-system-dot-collections-dot-generic-dot-ienumerable-devexpress-dot-xtramap-dot-mapitem-system-dot-double-x29.md
Zooms the map to fit the area that contains items sent as a parameter.
Namespace : DevExpress.XtraMap
Assembly : DevExpress.XtraMap.v25.2.dll
NuGet Package : DevExpress.Win.Map
public void ZoomToFit(
IEnumerable<MapItem> items,
double paddingFactor
)
Public Sub ZoomToFit(
items As IEnumerable(Of MapItem),
paddingFactor As Double
)
| Name | Type | Description |
|---|---|---|
| items | IEnumerable<MapItem> |
A IEnumerable object that contains MapItem descendant objects that should be visible on a map after it is zoomed.
| | paddingFactor | Double |
A Double object, which tunes the border size around visible map items.
|
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 a map with paddingFactor equal to 0.3:
map.ZoomToFit(mapItemStorage.Items, 0.3);
map.ZoomToFit(mapItemStorage.Items, 0.3)
The following code snippets (auto-collected from DevExpress Examples) contain references to the ZoomToFit(IEnumerable<MapItem>, Double) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
winforms-map-get-geo-point-info-from-bing-geocode-service/CS/RequestLocationInformation/Form1.cs#L95
private void OnLayerItemsGenerating(object sender, LayerItemsGeneratingEventArgs e) {
mapControl.ZoomToFit(e.Items, 0.4);
}
map-for-winforms-azure-geocoding/CS/AzureGeocoding/Form1.cs#L90
private void OnLayerItemsGenerating(object sender, LayerItemsGeneratingEventArgs e) {
mapControl1.ZoomToFit(e.Items, 0.4);
}
Private Sub OnLayerItemsGenerating(ByVal sender As Object, ByVal e As LayerItemsGeneratingEventArgs)
mapControl.ZoomToFit(e.Items, 0.4)
End Sub
map-for-winforms-azure-geocoding/VB/AzureGeocoding/Form1.vb#L99
Private Sub OnLayerItemsGenerating(ByVal sender As Object, ByVal e As LayerItemsGeneratingEventArgs)
mapControl1.ZoomToFit(e.Items, 0.4)
End Sub
See Also