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

VisualizationLayer kml and polylines

1 Answer 82 Views
Map
This is a migrated thread and some comments may be shown as answers.
Jeroen
Top achievements
Rank 1
Jeroen asked on 23 Jun 2014, 09:54 AM
Hi,

I'm looking into replacing InformationLayers in my application with VisualizationLayers, but I'm having trouble drawing lines.

Firstly, I'm looking for an alternative for the MapPolyLine I'm currently using to draw lines. According to what I've found, I should be using PolyLineData, but I can't get that to work at all, and I can't find any examples either.

Secondly, I'm currently using KML on a few layers as well.

layer.ItemsSource = KmlReader.Read(routeModel.RouteSegmentXML1.KML);

This doesn't seem to work either, and I can't find any info or examples on this. The only info I can find always deals with InformationLayer...

Also, I need to be able to handle everything in code-behind (C#). Xaml is no use to me.
Any help would be much appreciated.

Kind regards,
Jeroen

1 Answer, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 23 Jun 2014, 04:44 PM
Hello Jeroen,

You can find an information about PolylineData in the Map Shape Data help article. You can create an instance of the PolylineData like the following:

PolylineData polyline = new PolylineData()
{
    ShapeFill = new MapShapeFill()
    {
        Stroke = new SolidColorBrush(Colors.Red),
        StrokeThickness = 2
    }
};
 
LocationCollection points = new LocationCollection();
points.Add(new Location(44.6957539183824, 23.3327663758679));
points.Add(new Location(44.1429369264591, 24.7498095849434));
points.Add(new Location(44.5131732087098, 27.4611884843576));
points.Add(new Location(45.2073941930888, 27.9275176988258));
 
polyline.Points = points;
 
this.visualizationLayer.Items.Add(polyline);


You should use the AsyncKmlReader instead of KmlReader for reading geospatial data which can be used in VisualizationLayer.
The sample code is below.
AsyncKmlReader reader = new AsyncKmlReader()
{
    Source = new Uri("kml-file path")
};
reader.PreviewReadShapeDataCompleted += reader_PreviewReadShapeDataCompleted;
reader.ReadAsync();
 
void reader_PreviewReadShapeDataCompleted(object sender, PreviewReadShapeDataCompletedEventArgs e)
{
    layer.ItemsSource = e.Items;
}

For more information please take a look at the Reading Map Shapes documentation article.

Regards,
Andrey Murzov
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
Map
Asked by
Jeroen
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Share this question
or