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

Attaching input events to the map shapes

The visualization engine based on the VisualizationLayer class separates geographical data and its visualization. The map shape data classes aren’t dependency objects. It means that you can’t attach input events to these classes directly. Instead you can attach events to the map shape visualization. It allows assigning of any input events supported by ContentPresenter to the map shape visual presentation.

The VisualizationLayer class provides 2 events:

  1. MapShapeVisualizationCreated: Occurs when map shape visualization object is created. Can be used to attach event handlers.

  2. MapShapeVisualizationRemoved: Occurs when map shape visualization object is removed. Can be used to detach event handlers.

Example 1

<dataVisualization:RadMap x:Name="radMap"  
                            ZoomLevel="8"  
                            Center="42.6957539183824, 23.3327663758679"> 
    <dataVisualization:RadMap.Provider> 
        <telerikMap:BingRestMapProvider ApplicationId="Bing_Map_Key"  
                        Mode="Aerial"  
                        IsLabelVisible="True" /> 
    </dataVisualization:RadMap.Provider> 
    <telerikMap:VisualizationLayer x:Name="visualizationLayer"  
                        MapShapeVisualizationCreated="MapShapeVisualizationCreated"  
                        MapShapeVisualizationRemoved="MapShapeVisualizationRemoved"> 
        <telerikMap:RectangleData Location="42.9457539183824,23.0827663758679"  
                        Height="0.5"  
                        Width="0.5"  
                        RadiusX="0.05"  
                        RadiusY="0.05"> 
            <telerikMap:RectangleData.ShapeFill> 
                <telerikMap:MapShapeFill Fill="#6FDFEFFF"  
                                Stroke="Blue"  
                                StrokeThickness="2" /> 
            </telerikMap:RectangleData.ShapeFill> 
            <telerikMap:RectangleData.HighlightFill> 
                <telerikMap:MapShapeFill Fill="#6F00EFFF"  
                                Stroke="Red"  
                                StrokeThickness="2" /> 
            </telerikMap:RectangleData.HighlightFill> 
        </telerikMap:RectangleData> 
    </telerikMap:VisualizationLayer> 
</dataVisualization:RadMap> 

Example 2

private void MapShapeVisualizationCreated(object sender, MapShapeOperationEventArgs e) 
{        
    // Attach events to the map shape visualization.         
} 
 
private void MapShapeVisualizationRemoved(object sender, MapShapeOperationEventArgs e) 
{ 
    // Detach events to the map shape visualization.         
}    
In this article
Not finding the help you need?