Edit this page

Set the Best View for the InformationLayer

In case you have a set of elements displayed by the InformationLayer, you might want to be able to display all of them in the visible area of the map and to set the optimal zoom for them. This can be done by using the Best View feature of the RadMap. To use it you have to call the GetBestView() method of the InformationLayer and pass its items to it. This method will return a LocationRect object which represents the best view for the items in the InformationLayer. You can use it in order to adjust the RadMap center and zoom level. Here is an example:

private void SetBestView()
{
    LocationRect rect = this.informationLayer.GetBestView(this.informationLayer.Items.Cast<object>());
    rect.MapControl = this.radMap;
    this.radMap.Center = rect.Center;
    this.radMap.ZoomLevel = rect.ZoomLevel;
}
Private Sub SetBestView()
    Dim rect As LocationRect = Me.informationLayer.GetBestView(Me.informationLayer.Items.Cast(Of Object)())
    rect.MapControl = Me.radMap
    Me.radMap.Center = rect.Center
    Me.radMap.ZoomLevel = rect.ZoomLevel
End Sub

See Also