wpf-devexpress-dot-xpf-dot-map-dot-mapcontrol-dot-zoomtofitlayeritems-x28-system-dot-double-x29.md
Zooms a map to fit items contained in all layers of the map.
Namespace : DevExpress.Xpf.Map
Assembly : DevExpress.Xpf.Map.v25.2.dll
NuGet Package : DevExpress.Wpf.Map
public void ZoomToFitLayerItems(
double paddingFactor = 0.15
)
Public Sub ZoomToFitLayerItems(
paddingFactor As Double = 0.15
)
| Name | Type | Default | Description |
|---|---|---|---|
| paddingFactor | Double | 0.15 |
A Double object, which tunes the border size around visible map items.
|
The ZoomToFitLayerItems method works as follows:
Calculates a bounding box around map items contained in map layers.
Zooms the map to fit the box.
The following image shows a map with the padding factor parameter set at 0.3:
map.ZoomToFitLayerItems(0.3);
map.ZoomToFitLayerItems(0.3)
To zoom in a map at application launch, call the ZoomToFitLayerItems method in the LayerBase.DataLoaded event handler:
<dxm:VectorLayer x:Name="layer1" DataLoaded="VectorLayer_DataLoaded">
<dxm:MapItemStorage>
<dxm:MapRectangle Height="21" Width="30">
<dxm:MapRectangle.Location>
<dxm:GeoPoint Longitude="41.3" Latitude="-54.5"/>
</dxm:MapRectangle.Location>
</dxm:MapRectangle>
</dxm:MapItemStorage>
</dxm:VectorLayer>
The DataLoaded event’s handler:
private void VectorLayer_DataLoaded(object sender, DataLoadedEventArgs e) {
mapControl.ZoomToFitLayerItems(0.3);
}
Private Sub VectorLayer_DataLoaded(ByVal sender As Object, ByVal e As DataLoadedEventArgs)
mapControl.ZoomToFitLayerItems(0.3)
End Sub
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the ZoomToFitLayerItems(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.
private void Button_Click(object sender, RoutedEventArgs e) {
map.ZoomToFitLayerItems(0.4);
}
Private Sub Button_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
Me.map.ZoomToFitLayerItems(0.4)
End Sub
See Also