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

Put a Mark on the clicked Location

If you want to mark the position where the user has clicked, you just have to handle the MapMouseClick event and add the desired mark element to the VisualizationLayer of the RadMap on the clicked location.

The following example will use a RadMap with one VisualizationLayer. The VisualizationLayer has its ItemTemplate property set. The DataTemplate contains a red Ellipse. In this example, the object that will be passed to the VisualizationLayer will be of type Location, so the MapLayer.Location property of the ellipse is bound to the DataContext of the template.

More detailed information regarding the data binding can be found in the Data Binding topic.

To learn how to define a provider for the RadMap, read the Providers topic.

Here is the code for the example:

Example 1

<dataVisualization:RadMap x:Name="radMap" 
                Width="600" 
                Height="480" 
                MapMouseClick="radMap_MapMouseClick"> 
    <dataVisualization:RadMap.Provider> 
        <telerikMap:BingRestMapProvider ApplicationId="Bing_Map_Key"  
                                        Mode="Aerial"  
                                        IsLabelVisible="True" /> 
        </dataVisualization:RadMap.Provider> 
    <telerikMap:VisualizationLayer x:Name="visualizationLayer"> 
        <telerikMap:VisualizationLayer.ItemTemplate> 
            <DataTemplate> 
                <Ellipse telerikMap:MapLayer.Location="{Binding}" 
                        Width="20" 
                        Height="20" 
                        Stroke="Red" 
                        StrokeThickness="3" 
                        Fill="Transparent"> 
                    <telerikMap:MapLayer.HotSpot> 
                        <dataVisualization:HotSpot X="0.5" 
                                        Y="0.5" /> 
                    </telerikMap:MapLayer.HotSpot> 
                </Ellipse> 
            </DataTemplate> 
        </telerikMap:VisualizationLayer.ItemTemplate>                 
    </telerikMap:VisualizationLayer> 
</dataVisualization:RadMap> 

Example 2

private void radMap_MapMouseClick( object sender, MapMouseRoutedEventArgs eventArgs ) 
{ 
    this.visualizationLayer.Items.Clear(); 
    this.visualizationLayer.Items.Add( eventArgs.Location ); 
} 

See Also

In this article
Not finding the help you need?