Hi!
How can i create a template that works on every element in a kml file i load from my computer?
.cs:
Loading the kml file works fine:
try
{
FileStream streamResource = File.Open("c:\\mapsource\\wildlife.kml",FileMode.Open,FileAccess.Read);
List<FrameworkElement> elements = Telerik.Windows.Controls.Map.KmlReader.Read(streamResource);
foreach (FrameworkElement element in elements)
{
this.informationLayer.Items.Add(element);
}
}
catch (Exception e)
{
MessageBox.Show("Error: " + e);
}
.xaml:
<StackPanel>
<Label HorizontalContentAlignment="Center" Content="Map" Width="{Binding Source={StaticResource configSource}, Path=DefaultMapWidth}" Height="30" Background="Gray"></Label>
<telerik:RadMap x:Name="radMap" Width="{Binding Source={StaticResource configSource}, Path=DefaultMapWidth}" Height="{Binding Source={StaticResource configSource}, Path=DefaultMapHeight}"
MouseDragMode="Drag"
ZoomBarVisibility="Collapsed"
NavigationVisibility="Collapsed">
<telerik:InformationLayer x:Name="informationLayer">
<telerik:InformationLayer.ItemTemplate>
<DataTemplate>
<Grid telerik:MapLayer.BaseZoomLevel="5" >
</Grid>
</DataTemplate>
</telerik:InformationLayer.ItemTemplate>
<!--<telerik:InformationLayer.Reader>
<telerik:MapShapeReader Source="c:/mapsource/Oil_Spills.kml" SourceType="Kml"/>
</telerik:InformationLayer.Reader>-->
</telerik:InformationLayer>
</telerik:RadMap>
</StackPanel>
KML:
Here's a part of the kml file that i'm using:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1">
<Document>
<name>wildlife-national-parks-india.kml</name>
<Placemark>
<name>Anshi National Park</name>
<description>
<![CDATA[
<p>Wildlife: Bonnet Macaque, Deer, Mouse Deer, Spotted Deer, Indian Bison, Malabar Civet, Malabar Giant Squirrel, Pangolin, Sloth Bear, Black Panther, Elephants, Tigers, Adjutant Stork, Ashy Woodswallow, Black-cre... </p>
<p>Plan your wildlife adventure holiday to <a href="http://www.world-wildlife-adventures.com/directory/india/wildlife-park.asp?sanctuary=Anshi+National+Park&state=Karnataka">Anshi National Park</a>, India...
read reviews by fellow wildlife enthusiasts, and share your own. For information about other parks in India and the rest of the world visit: <a href="http://www.world-wildlife-adventures.com/">World Wildlife Adventures</a></p>
]]>
</description>
<Point>
<coordinates>74.39598,15.07237,0</coordinates>
</Point>
</Placemark>
<Placemark>
<name>Balphakram National Park</name>
<description>
<![CDATA[
<p>Wildlife: Indian Elephant, Bengal Tiger, Leopard, Clouded Leopard, Wild Buffalo, Gaur (Indian Bison), Muntjac (Barking Deer), Hoolock (White-browed) Gibbon, Assamese Macaque, Pig-tailed Macaque, Capped Langur (... </p>
<p>Plan your wildlife adventure holiday to <a href="http://www.world-wildlife-adventures.com/directory/india/wildlife-park.asp?sanctuary=Balphakram+National+Park&state=Meghalaya">Balphakram National Park</a>, India...
read reviews by fellow wildlife enthusiasts, and share your own. For information about other parks in India and the rest of the world visit: <a href="http://www.world-wildlife-adventures.com/">World Wildlife Adventures</a></p>
]]>
</description>
<Point>
<coordinates>90.82664,25.25261,0</coordinates>
</Point>
</Placemark>
It's important that i'm able to format the name and description.
I did not find any examples on this, so i hope you can help.
Thanks in advance.
How can i create a template that works on every element in a kml file i load from my computer?
.cs:
Loading the kml file works fine:
try
{
FileStream streamResource = File.Open("c:\\mapsource\\wildlife.kml",FileMode.Open,FileAccess.Read);
List<FrameworkElement> elements = Telerik.Windows.Controls.Map.KmlReader.Read(streamResource);
foreach (FrameworkElement element in elements)
{
this.informationLayer.Items.Add(element);
}
}
catch (Exception e)
{
MessageBox.Show("Error: " + e);
}
.xaml:
<StackPanel>
<Label HorizontalContentAlignment="Center" Content="Map" Width="{Binding Source={StaticResource configSource}, Path=DefaultMapWidth}" Height="30" Background="Gray"></Label>
<telerik:RadMap x:Name="radMap" Width="{Binding Source={StaticResource configSource}, Path=DefaultMapWidth}" Height="{Binding Source={StaticResource configSource}, Path=DefaultMapHeight}"
MouseDragMode="Drag"
ZoomBarVisibility="Collapsed"
NavigationVisibility="Collapsed">
<telerik:InformationLayer x:Name="informationLayer">
<telerik:InformationLayer.ItemTemplate>
<DataTemplate>
<Grid telerik:MapLayer.BaseZoomLevel="5" >
</Grid>
</DataTemplate>
</telerik:InformationLayer.ItemTemplate>
<!--<telerik:InformationLayer.Reader>
<telerik:MapShapeReader Source="c:/mapsource/Oil_Spills.kml" SourceType="Kml"/>
</telerik:InformationLayer.Reader>-->
</telerik:InformationLayer>
</telerik:RadMap>
</StackPanel>
KML:
Here's a part of the kml file that i'm using:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1">
<Document>
<name>wildlife-national-parks-india.kml</name>
<Placemark>
<name>Anshi National Park</name>
<description>
<![CDATA[
<p>Wildlife: Bonnet Macaque, Deer, Mouse Deer, Spotted Deer, Indian Bison, Malabar Civet, Malabar Giant Squirrel, Pangolin, Sloth Bear, Black Panther, Elephants, Tigers, Adjutant Stork, Ashy Woodswallow, Black-cre... </p>
<p>Plan your wildlife adventure holiday to <a href="http://www.world-wildlife-adventures.com/directory/india/wildlife-park.asp?sanctuary=Anshi+National+Park&state=Karnataka">Anshi National Park</a>, India...
read reviews by fellow wildlife enthusiasts, and share your own. For information about other parks in India and the rest of the world visit: <a href="http://www.world-wildlife-adventures.com/">World Wildlife Adventures</a></p>
]]>
</description>
<Point>
<coordinates>74.39598,15.07237,0</coordinates>
</Point>
</Placemark>
<Placemark>
<name>Balphakram National Park</name>
<description>
<![CDATA[
<p>Wildlife: Indian Elephant, Bengal Tiger, Leopard, Clouded Leopard, Wild Buffalo, Gaur (Indian Bison), Muntjac (Barking Deer), Hoolock (White-browed) Gibbon, Assamese Macaque, Pig-tailed Macaque, Capped Langur (... </p>
<p>Plan your wildlife adventure holiday to <a href="http://www.world-wildlife-adventures.com/directory/india/wildlife-park.asp?sanctuary=Balphakram+National+Park&state=Meghalaya">Balphakram National Park</a>, India...
read reviews by fellow wildlife enthusiasts, and share your own. For information about other parks in India and the rest of the world visit: <a href="http://www.world-wildlife-adventures.com/">World Wildlife Adventures</a></p>
]]>
</description>
<Point>
<coordinates>90.82664,25.25261,0</coordinates>
</Point>
</Placemark>
It's important that i'm able to format the name and description.
I did not find any examples on this, so i hope you can help.
Thanks in advance.