This is a migrated thread and some comments may be shown as answers.

Load mulitple KML files

3 Answers 54 Views
Map
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 12 Mar 2012, 11:34 PM
Hi..
I have mulitple KML files how can I load them all and allow a user to click on a 'shape' and bring up a messagebox?
(I have the fifty states and want break up dialog box when each is clicked)
Thanks in advance

3 Answers, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 15 Mar 2012, 08:55 AM
Hello Jon,

You can use the KmlReader to read KML files. You can find more details here:

http://www.telerik.com/help/silverlight/radmap-features-kml-data-import.html

You can use the following code to identify the shape where  the mouse button is clicked and show dialog:

<telerik:RadMap x:Name="RadMap1"
        Center="40,-100"
        ZoomLevel="3"
        MapMouseClick="MapMouseClick">
    <telerik:RadMap.Provider>
        <telerik:OpenStreetMapProvider />
    </telerik:RadMap.Provider>
    <telerik:InformationLayer x:Name="InformationLayer">
    </telerik:InformationLayer>
</telerik:RadMap>



public partial class MainPage : UserControl
{
    public MainPage()
    {
        InitializeComponent();
    }
 
    private void MapMouseClick(object sender, Telerik.Windows.Controls.Map.MapMouseRoutedEventArgs eventArgs)
    {
        IEnumerable<object> list = this.InformationLayer.GetItemsInLocation(eventArgs.Location);
        foreach (object item in list)
        {
            MapShape shape = item as MapShape;
            if (shape != null)
            {
                MessageBox.Show("Sate: " + shape.ExtendedData.GetValue("STATE"));
                break;
            
        }
    }
}

Regards,
Andrey Murzov
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Jon
Top achievements
Rank 1
answered on 15 Mar 2012, 12:14 PM
Thanks.. BUT the tooltips prevent the mouse click when I add this.. How can I do both?

 

void mapShapeReader_PreviewReadCompleted(object sender, PreviewReadShapesCompletedEventArgs eventArgs)

{

 

 

foreach (FrameworkElement element in eventArgs.Items)

{

 

MapShape polygon = element as MapShape;

 

if (polygon != null)

 

{

 

 var tooltip = new ToolTip();

 

 tooltip.Content = polygon.ExtendedData;

 

 tooltip.ContentTemplate = this.Resources["ToolTipTemplate"] as DataTemplate;

 

 ToolTipService.SetToolTip(element, tooltip);

 

 polygon.MouseEnter += new MouseEventHandler(polygon_MouseEnter);

 

}

 

 

 

}


0
Andrey
Telerik team
answered on 20 Mar 2012, 09:07 AM
Hi Jon,

The MouseEnter event can't be used for implementing the reaction on mouse click. You should use MouseLeftButtonDown and MouseLeftButtonUp events instead.

Regards,
Andrey Murzov
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
Map
Asked by
Jon
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Jon
Top achievements
Rank 1
Share this question
or