Load mulitple KML files

4 posts, 0 answers
  1. Jon
    Jon avatar
    539 posts
    Member since:
    Apr 2004

    Posted 12 Mar 2012 Link to this post

    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
  2. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 15 Mar 2012 Link to this post

    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 >>
  3. DevCraft banner
  4. Jon
    Jon avatar
    539 posts
    Member since:
    Apr 2004

    Posted 15 Mar 2012 Link to this post

    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);

     

    }

     

     

     

    }


  5. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 20 Mar 2012 Link to this post

    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 >>
Back to Top