mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
60 lines
1.6 KiB
C#
60 lines
1.6 KiB
C#
// XAML Map Control - http://xamlmapcontrol.codeplex.com/
|
|
// © 2015 Clemens Fischer
|
|
// Licensed under the Microsoft Public License (Ms-PL)
|
|
|
|
using System.Linq;
|
|
#if WINDOWS_RUNTIME
|
|
using Windows.UI.Xaml.Media;
|
|
#else
|
|
using System.Windows.Media;
|
|
#endif
|
|
|
|
namespace MapControl
|
|
{
|
|
public partial class MapPolyline
|
|
{
|
|
public MapPolyline()
|
|
{
|
|
Data = new PathGeometry();
|
|
}
|
|
|
|
protected override void UpdateData()
|
|
{
|
|
var geometry = (PathGeometry)Data;
|
|
var locations = Locations;
|
|
Location first;
|
|
|
|
if (ParentMap != null && locations != null && (first = locations.FirstOrDefault()) != null)
|
|
{
|
|
var figure = new PathFigure
|
|
{
|
|
StartPoint = ParentMap.MapTransform.Transform(first),
|
|
IsClosed = IsClosed,
|
|
IsFilled = IsClosed
|
|
};
|
|
|
|
var segment = new PolyLineSegment();
|
|
|
|
foreach (var location in locations.Skip(1))
|
|
{
|
|
segment.Points.Add(ParentMap.MapTransform.Transform(location));
|
|
}
|
|
|
|
if (segment.Points.Count > 0)
|
|
{
|
|
figure.Segments.Add(segment);
|
|
}
|
|
|
|
geometry.Figures.Clear();
|
|
geometry.Figures.Add(figure);
|
|
geometry.Transform = ParentMap.ViewportTransform;
|
|
}
|
|
else
|
|
{
|
|
geometry.Figures.Clear();
|
|
geometry.ClearValue(Geometry.TransformProperty);
|
|
}
|
|
}
|
|
}
|
|
}
|