Edit this page

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 InformationLayer of the RadMap on the clicked location.

The following example will use a RadMap with one InformationLayer. The InformationLayer has its ItemTemplate property set. The DataTemplate contains a red Ellipse. In this example, the object that will be passed to the InformationLayer 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:

XAML

<telerik:RadMap x:Name="radMap"
                Width="600"
                Height="480"
                MapMouseClick="radMap_MapMouseClick">
    <telerik:InformationLayer x:Name="informationLayer">
        <telerik:InformationLayer.ItemTemplate>
            <DataTemplate>
                <Ellipse telerik:MapLayer.Location="{Binding}"
                            Width="20"
                            Height="20"
                            Stroke="Red"
                            StrokeThickness="3"
                            Fill="Transparent">
                    <telerik:MapLayer.HotSpot>
                        <telerik:HotSpot X="0.5"
                                            Y="0.5" />
                    </telerik:MapLayer.HotSpot>
                </Ellipse>
            </DataTemplate>
        </telerik:InformationLayer.ItemTemplate>
    </telerik:InformationLayer>
</telerik:RadMap>

C#

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

VB.NET

Private Sub radMap_MapMouseClick(ByVal sender As Object, ByVal eventArgs As MapMouseRoutedEventArgs)
    Me.informationLayer.Items.Clear()
    Me.informationLayer.Items.Add(eventArgs.Location)
End Sub

See Also