wpf-devexpress-dot-xpf-dot-map-dot-mapcontrol-dot-zoomtofitlayeritems-x28-system-dot-collections-dot-generic-dot-ienumerable-devexpress-dot-xpf-dot-map-dot-layerbase-system-dot-boolean-system-dot-double-x29.md
Zooms a map to fit vector items contained in the specified map layers. Allows you to specify whether to use an integer zoom level, and set the padding factor.
Namespace : DevExpress.Xpf.Map
Assembly : DevExpress.Xpf.Map.v25.2.dll
NuGet Package : DevExpress.Wpf.Map
public void ZoomToFitLayerItems(
IEnumerable<LayerBase> layers,
bool roundZoomLevel,
double paddingFactor = 0.15
)
Public Sub ZoomToFitLayerItems(
layers As IEnumerable(Of LayerBase),
roundZoomLevel As Boolean,
paddingFactor As Double = 0.15
)
| Name | Type | Description |
|---|---|---|
| layers | IEnumerable<LayerBase> |
A collection of layers that contain items to be displayed on the map.
| | roundZoomLevel | Boolean |
Specifies whether to round the zoom level value.
|
| Name | Type | Default | Description |
|---|---|---|---|
| paddingFactor | Double | 0.15 |
Specifies the size of the border around displayed 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 to 0.3:
The following example shows how to zoom a map to display items contained in the specified map layers:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:MapApp"
xmlns:dxc="http://schemas.devexpress.com/winfx/2008/xaml/charts"
xmlns:dxm="http://schemas.devexpress.com/winfx/2008/xaml/map"
x:Class="MapApp.MainWindow"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800" Loaded="OnWindowLoaded">
<Grid>
<dxm:MapControl x:Name="mapControl">
<dxm:VectorLayer x:Name="vectorLayer">
<dxm:MapItemStorage x:Name="mapItemStorage">
<dxm:MapDot Location="51.30, 0.07" Size="20" Fill="Wheat"/>
<dxm:MapDot Location="52.31, 13.23" Size="20" Fill="Gold"/>
<dxm:MapDot Location="48.51, 2.21" Size="20" Fill="CadetBlue"/>
<dxm:MapDot Location="41.54, 12.3" Size="20" Fill="Red"/>
<dxm:MapDot Location="40.23, -3.43" Size="20" Fill="Green"/>
</dxm:MapItemStorage>
</dxm:VectorLayer>
</dxm:MapControl>
</Grid>
</Window>
using DevExpress.Xpf.Map;
using System.Windows;
namespace MapApp {
public partial class MainWindow : Window {
private void OnWindowLoaded(object sender, RoutedEventArgs e) {
mapControl.ZoomToFitLayerItems(layers: new LayerBase[] { vectorLayer }, roundZoomLevel: true, paddingFactor: 0.15);
}
}
}
Imports DevExpress.Xpf.Map
Namespace MapApp
Public Partial Class MainWindow
Inherits Window
Private Sub OnWindowLoaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
mapControl.ZoomToFitLayerItems(layers:=New LayerBase() {vectorLayer}, roundZoomLevel:=True, paddingFactor:=0.15)
End Sub
End Class
End Namespace
See Also