Back to Devexpress

MapControl.ZoomToFitLayerItems(IEnumerable<LayerBase>, Double) Method

windowsforms-devexpress-dot-xtramap-dot-mapcontrol-dot-zoomtofitlayeritems-x28-system-dot-collections-dot-generic-dot-ienumerable-devexpress-dot-xtramap-dot-layerbase-system-dot-double-x29.md

latest2.9 KB
Original Source

MapControl.ZoomToFitLayerItems(IEnumerable<LayerBase>, Double) Method

Zooms the map to fit items contained in the specified set of LayerBase class descendant objects.

Namespace : DevExpress.XtraMap

Assembly : DevExpress.XtraMap.v25.2.dll

NuGet Package : DevExpress.Win.Map

Declaration

csharp
public void ZoomToFitLayerItems(
    IEnumerable<LayerBase> layers,
    double paddingFactor
)
vb
Public Sub ZoomToFitLayerItems(
    layers As IEnumerable(Of LayerBase),
    paddingFactor As Double
)

Parameters

NameTypeDescription
layersIEnumerable<LayerBase>

A IEnumerable object, containing LayerBase class descendant objects.

| | paddingFactor | Double |

A Double value, which tunes the border size around visible map items.

|

Remarks

When vector items are loaded at runtime, the ZoomToFitLayerItems method should be called from LayerBase.DataLoaded event handler.

The ZoomToFitLayerItems 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.

Example

The following image shows a map that is zoomed with paddingFactor equal to 0.3:

csharp
using DevExpress.XtraMap;

private void OnVectorLayerDataLoaded(object sender, DataLoadedEventArgs e) {
    mapControl1.ZoomToFitLayerItems(new LayerBase[] { vectorLayer }, 0.3);
}
vb
Imports DevExpress.XtraMap

Private Sub OnVectorLayerDataLoaded(ByVal sender As Object, ByVal e As DataLoadedEventArgs)
    mapControl1.ZoomToFitLayerItems(New LayerBase() {vectorLayer}, 0.3)
End Sub

See Also

MapControl Class

MapControl Members

DevExpress.XtraMap Namespace