kml Files

9 posts, 0 answers
  1. Dharmesh Trivedi
    Dharmesh Trivedi avatar
    24 posts
    Member since:
    Oct 2009

    Posted 28 Nov 2009 Link to this post

    I would like four kml files as follows

    1 Southern California
    2 Northern California
    3 Metro New York State(includes New York City and surrounding area)
    4 Upstate New York State (Buffalo , Albany etc)

    if you can provide or tell me how to get it, I really appreciated it.

    Thanks
  2. Velin
    Admin
    Velin avatar
    391 posts

    Posted 02 Dec 2009 Link to this post

    Hello Dharmesh Trivedi,

    Unfortunately, we do not provide kml data with our Map control but there are some public online geographic data repositories(like http://finder.geocommons.com/ ) where you could search and find the necessary information.

    Our online examples use simplified kml data files which you can use if applicable.

    Please, find these files attached.

    Hope this will help.

    All the best,
    Velin
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. DevCraft banner
  4. Rowena Du
    Rowena Du avatar
    4 posts
    Member since:
    Nov 2009

    Posted 15 Apr 2010 Link to this post

    Hello,
           I have done  the  Florida.kml  instead of  the eu.kml ,however,when I  am running the  demo,the Radmap  always displays the  eu.kml not the Florida.kml .Why ? Is  there other items for setting?
          In advance thanks!
  5. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 16 Apr 2010 Link to this post

    Hi Rowena Du,

    You should be sure that you have done the following:

    1. Set "Build Action" to the "Resource" for the Florida.kml file.
    2. Change code-behind (C# or VB.NET) to use "Florida.kml" instead of "eu.kml"

    For example:

    <UserControl x:Class="Telerik.RadMap.Silverlight.Q1SL3.MainPage"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:map="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.DataVisualization"
                 xmlns:layer="clr-namespace:Telerik.Windows.Controls.Map;assembly=Telerik.Windows.Controls.DataVisualization"
                 Width="600" Height="500">
      <Grid x:Name="LayoutRoot">
            <map:RadMap x:Name="radMap" 
                        Center="28.788728690592,-88.388062504629"
                        ZoomLevel="5">
                <layer:InformationLayer Name="informationLayer" />
            </map:RadMap>
        </Grid>
    </UserControl>

    using System;
    using System.Collections.Generic;
    using System.Windows.Resources;
    using System.Windows;
    using System.Windows.Controls;
    using Telerik.Windows.Controls.Map;
      
    namespace Telerik.RadMap.Silverlight.Q1SL3
    {
        public partial class MainPage : UserControl
        {
            private string applicationId = "your application ID";
        
            public MainPage()
            {
                InitializeComponent();
      
                this.Loaded += new RoutedEventHandler(MainPage_Loaded);
            }
      
            private void MainPage_Loaded(object sender, RoutedEventArgs e)
            {
                BingMapProvider provider = new BingMapProvider(MapMode.Aerial, true, this.applicationId);
                this.radMap.Provider = provider;
      
                // loading the kml file
                StreamResourceInfo streamInfo = Application.GetResourceStream(
                    new Uri("/Telerik.RadMap.Silverlight.Q1SL3;component/Resources/Florida.kml", UriKind.RelativeOrAbsolute));
                List<FrameworkElement> list = KmlReader.Read(streamInfo.Stream);
      
                this.informationLayer.ItemsSource = list;
            }
        }
    }

    Pay attention, that we use name of the KML file (Florida.kml) to read it from resources.

    Greetings,
    Andrey Murzov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  6. Rowena Du
    Rowena Du avatar
    4 posts
    Member since:
    Nov 2009

    Posted 20 Apr 2010 Link to this post

    Thank you very much!
    It works!
    Well  done! 
    <?xml version="1.0" encoding="UTF-8"?>  
    <kml xmlns="http://earth.google.com/kml/2.1">  
    <Folder> 
    <name>county_point</name> 
    <visibility>0</visibility> 
      <Folder> 
      <name>三原县                                                                                                                                                                                                                                                        </name> 
      <visibility>0</visibility> 
        <Placemark> 
        <name>三原县                                                                                                                                                                                                                                                        </name> 
        <visibility>0</visibility> 
        <description><![CDATA[三原县                                                                                                                                                                                                                                                        ]]></description>  
          <Point> 
              <coordinates>9.61497256181836E-315,4.98875943181475E250,0</coordinates> 
          </Point> 
          <TimeSpan> 
              <begin>三原县                                                                                                                                                                                                                                                        </begin> 
              <end>三原县                                                                                                                                                                                                                                                        </end> 
          </TimeSpan> 
        </Placemark> 
      </Folder> 
      <Folder> 
      <name>灞桥区                                                                                                                                                                                                                                                        </name> 
      <visibility>0</visibility> 
        <Placemark> 
        <name>灞桥区                                                                                                                                                                                                                                                        </name> 
        <visibility>0</visibility> 
        <description><![CDATA[灞桥区                                                                                                                                                                                                                                                        ]]></description>  
          <Point> 
              <coordinates>9.61497256181836E-315,4.98875943181475E250,0</coordinates> 
          </Point> 
          <TimeSpan> 
              <begin>灞桥区                                                                                                                                                                                                                                                        </begin> 
              <end>灞桥区                                                                                                                                                                                                                                                        </end> 
          </TimeSpan> 
        </Placemark> 
      </Folder> 
      <Folder> 
      <name>临潼县                                                                                                                                                                                                                                                        </name> 
      <visibility>0</visibility> 
        <Placemark> 
        <name>临潼县                                                                                                                                                                                                                                                        </name> 
        <visibility>0</visibility> 
        <description><![CDATA[临潼县                                                                                                                                                                                                                                                        ]]></description>  
          <Point> 
              <coordinates>9.61497256181836E-315,4.98875943181475E250,0</coordinates> 
          </Point> 
          <TimeSpan> 
              <begin>临潼县                                                                                                                                                                                                                                                        </begin> 
              <end>临潼县                                                                                                                                                                                                                                                        </end> 
          </TimeSpan> 
        </Placemark> 
      </Folder> 
      <Folder> 
      <name>高陵县                                                                                                                                                                                                                                                        </name> 
      <visibility>0</visibility> 
        <Placemark> 
        <name>高陵县                                                                                                                                                                                                                                                        </name> 
        <visibility>0</visibility> 
        <description><![CDATA[高陵县                                                                                                                                                                                                                                                        ]]></description>  
          <Point> 
              <coordinates>9.61497256181836E-315,4.98875943181475E250,0</coordinates> 
          </Point> 
          <TimeSpan> 
              <begin>高陵县                                                                                                                                                                                                                                                        </begin> 
              <end>高陵县                                                                                                                                                                                                                                                        </end> 
          </TimeSpan> 
        </Placemark> 
      </Folder> 
      <Folder> 
      <name>阎良区                                                                                                                                                                                                                                                        </name> 
      <visibility>0</visibility> 
        <Placemark> 
        <name>阎良区                                                                                                                                                                                                                                                        </name> 
        <visibility>0</visibility> 
        <description><![CDATA[阎良区                                                                                                                                                                                                                                                        ]]></description>  
          <Point> 
              <coordinates>9.61497256181836E-315,4.98875943181475E250,0</coordinates> 
          </Point> 
          <TimeSpan> 
              <begin>阎良区                                                                                                                                                                                                                                                        </begin> 
              <end>阎良区                                                                                                                                                                                                                                                        </end> 
          </TimeSpan> 
        </Placemark> 
      </Folder> 
      <Folder> 
      <name>户县                                                                                                                                                                                                                                                          </name> 
      <visibility>0</visibility> 
        <Placemark> 
        <name>户县                                                                                                                                                                                                                                                          </name> 
        <visibility>0</visibility> 
        <description><![CDATA[户县                                                                                                                                                                                                                                                          ]]></description>  
          <Point> 
              <coordinates>9.61497256181836E-315,4.98875943181475E250,0</coordinates> 
          </Point> 
          <TimeSpan> 
              <begin>户县                                                                                                                                                                                                                                                          </begin> 
              <end>户县                                                                                                                                                                                                                                                          </end> 
          </TimeSpan> 
        </Placemark> 
      </Folder> 
      <Folder> 
      <name>长安县                                                                                                                                                                                                                                                        </name> 
      <visibility>0</visibility> 
        <Placemark> 
        <name>长安县                                                                                                                                                                                                                                                        </name> 
        <visibility>0</visibility> 
        <description><![CDATA[长安县                                                                                                                                                                                                                                                        ]]></description>  
          <Point> 
              <coordinates>9.61497256181836E-315,4.98875943181475E250,0</coordinates> 
          </Point> 
          <TimeSpan> 
              <begin>长安县                                                                                                                                                                                                                                                        </begin> 
              <end>长安县                                                                                                                                                                                                                                                        </end> 
          </TimeSpan> 
        </Placemark> 
      </Folder> 
      <Folder> 
      <name>周至县                                                                                                                                                                                                                                                        </name> 
      <visibility>0</visibility> 
        <Placemark> 
        <name>周至县                                                                                                                                                                                                                                                        </name> 
        <visibility>0</visibility> 
        <description><![CDATA[周至县                                                                                                                                                                                                                                                        ]]></description>  
          <Point> 
              <coordinates>9.61497256181836E-315,4.98875943181475E250,0</coordinates> 
          </Point> 
          <TimeSpan> 
              <begin>周至县                                                                                                                                                                                                                                                        </begin> 
              <end>周至县                                                                                                                                                                                                                                                        </end> 
          </TimeSpan> 
        </Placemark> 
      </Folder> 
      <Folder> 
      <name>蓝田县                                                                                                                                                                                                                                                        </name> 
      <visibility>0</visibility> 
        <Placemark> 
        <name>蓝田县                                                                                                                                                                                                                                                        </name> 
        <visibility>0</visibility> 
        <description><![CDATA[蓝田县                                                                                                                                                                                                                                                        ]]></description>  
          <Point> 
              <coordinates>9.61497256181836E-315,4.98875943181475E250,0</coordinates> 
          </Point> 
          <TimeSpan> 
              <begin>蓝田县                                                                                                                                                                                                                                                        </begin> 
              <end>蓝田县                                                                                                                                                                                                                                                        </end> 
          </TimeSpan> 
        </Placemark> 
      </Folder> 
    </Folder> 
    </kml> 
     

         Unfortuanely,there is  another problem  :How to get  the kml map's center,just like "Center="28.788728690592,-88.388062504629" "?Now ,I offer a kml file  ,please help me find out the center and let me know.
          Excuse me,private string applicationId = "your application ID";  What is the  application ID  ? Does it  register from the  Window Live? And is it  a must?
  7. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 21 Apr 2010 Link to this post

    Hello Rowena Du,

    If you load data from the KML file, then you have a list of the map shapes which represents elements on your map. You have to walk through this list and select every element which is MapPolyline. For every polyline you have to walk through the Points collection and select most NorthEast and most SouthWest points.

    You can use RadMap.SetView(LocationRect rect) method to set best view for the loaded objects.

    // loading the kml file
    StreamResourceInfo streamInfo = Application.GetResourceStream(
        new Uri("/Telerik.RadMap.Silverlight.Q1SL3;component/Resources/California.kml", UriKind.RelativeOrAbsolute));
    List<FrameworkElement> list = KmlReader.Read(streamInfo.Stream);
      
    // look for the North-East and South-West coordinates
    Location northEast = Location.Empty;
    Location southWest = Location.Empty;
    foreach (FrameworkElement shape in list)
    {
        MapPolyline polyline = shape as MapPolyline;
        if (polyline != null)
        {
            foreach (Location location in polyline.Points)
            {
                if (northEast.IsEmpty)
                {
                    northEast = location;
                }
                else
                {
                    northEast.Latitude = Math.Max(northEast.Latitude, location.Latitude);
                    northEast.Longitude = Math.Max(northEast.Longitude, location.Longitude);
                }
      
                if (southWest.IsEmpty)
                {
                    southWest = location;
                }
                else
                {
                    southWest.Latitude = Math.Min(southWest.Latitude, location.Latitude);
                    southWest.Longitude = Math.Min(southWest.Longitude, location.Longitude);
                }
            }
        }
    }
      
    LocationRect viewRectangle = new LocationRect(northEast, southWest);
    this.radMap.SetView(viewRectangle);

    The application ID -- yes, this is a must when using Bing maps. Please, find more details in this article.

    All the best,
    Andrey Murzov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  8. Rowena Du
    Rowena Du avatar
    4 posts
    Member since:
    Nov 2009

    Posted 24 Apr 2010 Link to this post

    Thank you again!
    Good luck!
  9. Rowena Du
    Rowena Du avatar
    4 posts
    Member since:
    Nov 2009

    Posted 26 Apr 2010 Link to this post

    Hello,
           I want to display my own kml data that converting shapefiles to KML  on the RadMap.However, my kml data  can't be displayed.Because my kml data's root is the <folder> not <Document>.So,could you recommend me a shptokml software ?

    Thanks a lot!
  10. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 29 Apr 2010 Link to this post

    Hello Rowena Du,

    I’m sorry,  we aren’t experienced with shape files conversion tools. But you can edit your KML file manually. There are few things you should change:

    1. 1. Replace <kml xmlns="http://earth.google.com/kml/2.1"> with simple <Document> tag (don’t forget to do it with closing tag as well.
    2. Remove wrapper <Folder> elements, so that the <Placemark> elements are on the level after root <Document> element.

    Sincerely yours,
    Andrey Murzov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top
DevCraft banner