New to Telerik UI for WinUI? Download free 30-day trial

How to restrict panning and zooming region in RadMap

Restrict zooming region in RadMap

You can restrict the zooming region in RadMap by setting the RadMap.MinZoomLevel / RadMap.MaxZoomLevel properties:

Example 1: Setting MinZoomLevel and MaxZoomLevel properties

<dataVisualization:RadMap x:Name="RadMap1"  
                ZoomLevel="13"  
                MinZoomLevel="10"  
                MaxZoomLevel="14"  
                Center="42.72481708629, 23.3176519378416"> 
    <dataVisualization:RadMap.Provider> 
        <telerikMap:BingRestMapProvider ApplicationId="Bing_Map_Key"  
                                        Mode="Aerial"  
                                        IsLabelVisible="True" /> 
    </dataVisualization:RadMap.Provider> 
</dataVisualization:RadMap> 

Restrict panning region in RadMap

You can restrict the panning region in RadMap by setting the RadMap.GeoBounds property that represents LocationRect instance:

Example 2: Setting GeoBounds property

<dataVisualization:RadMap x:Name="RadMap1"  
        ZoomLevel="15" 
        MinZoomLevel="15" 
        GeoBounds="42.3683598045287, -71.0789727419614, 3.9167707221002743, 2.1883037274811104"> 
    <dataVisualization:RadMap.Provider> 
        <telerikMap:BingRestMapProvider ApplicationId="Bing_Map_Key"  
                                        Mode="Aerial"  
                                        IsLabelVisible="True" /> 
    </dataVisualization:RadMap.Provider> 
</dataVisualization:RadMap> 

The third and fourth parameters (Width and Height) in the LocationRect definition specify size of the rectangle in the distance units used on the map (kilometers or miles).

RadMap.GeoBounds and MapProvider.GeoBounds serve different purposes in RadMap. The former restricts panning region, while the latter limit the size of the geographical region covered by the respective provider and allows creation of specific “map windows” over the map.

In this article
Not finding the help you need?