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

kml Files

8 Answers 196 Views
Map
This is a migrated thread and some comments may be shown as answers.
Dharmesh Trivedi
Top achievements
Rank 1
Dharmesh Trivedi asked on 28 Nov 2009, 08:27 PM
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

8 Answers, 1 is accepted

Sort by
0
Velin
Telerik team
answered on 02 Dec 2009, 04:33 PM
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.
0
Rowena Du
Top achievements
Rank 1
answered on 15 Apr 2010, 09:18 AM
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!
0
Andrey
Telerik team
answered on 16 Apr 2010, 01:48 PM
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.
0
Rowena Du
Top achievements
Rank 1
answered on 20 Apr 2010, 10:56 AM
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?
0
Andrey
Telerik team
answered on 21 Apr 2010, 03:23 PM
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.
0
Rowena Du
Top achievements
Rank 1
answered on 24 Apr 2010, 09:38 AM
Thank you again!
Good luck!
0
Rowena Du
Top achievements
Rank 1
answered on 27 Apr 2010, 04:56 AM
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!
0
Andrey
Telerik team
answered on 29 Apr 2010, 08:02 AM
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.
Tags
Map
Asked by
Dharmesh Trivedi
Top achievements
Rank 1
Answers by
Velin
Telerik team
Rowena Du
Top achievements
Rank 1
Andrey
Telerik team
Share this question
or