2017-06-25 23:05:48 +02:00
|
|
|
|
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
2021-01-13 21:19:27 +01:00
|
|
|
|
// © 2021 Clemens Fischer
|
2012-11-22 21:42:29 +01:00
|
|
|
|
// Licensed under the Microsoft Public License (Ms-PL)
|
|
|
|
|
|
|
|
|
|
|
|
using Windows.Foundation;
|
2013-04-21 23:56:08 +02:00
|
|
|
|
using Windows.UI;
|
2012-11-22 21:42:29 +01:00
|
|
|
|
using Windows.UI.Xaml;
|
2015-08-09 20:04:44 +02:00
|
|
|
|
using Windows.UI.Xaml.Media;
|
2012-11-22 21:42:29 +01:00
|
|
|
|
|
|
|
|
|
|
namespace MapControl
|
|
|
|
|
|
{
|
|
|
|
|
|
public partial class MapBase
|
|
|
|
|
|
{
|
|
|
|
|
|
public static readonly DependencyProperty ForegroundProperty = DependencyProperty.Register(
|
2017-06-25 23:05:48 +02:00
|
|
|
|
nameof(Foreground), typeof(Brush), typeof(MapBase),
|
2015-11-11 19:48:50 +01:00
|
|
|
|
new PropertyMetadata(new SolidColorBrush(Colors.Black)));
|
2012-11-22 21:42:29 +01:00
|
|
|
|
|
2013-12-05 17:56:04 +01:00
|
|
|
|
public static readonly DependencyProperty CenterProperty = DependencyProperty.Register(
|
2017-06-25 23:05:48 +02:00
|
|
|
|
nameof(Center), typeof(Location), typeof(MapBase),
|
2015-11-11 19:48:50 +01:00
|
|
|
|
new PropertyMetadata(new Location(), (o, e) => ((MapBase)o).CenterPropertyChanged((Location)e.NewValue)));
|
2013-12-05 17:56:04 +01:00
|
|
|
|
|
|
|
|
|
|
public static readonly DependencyProperty TargetCenterProperty = DependencyProperty.Register(
|
2017-06-25 23:05:48 +02:00
|
|
|
|
nameof(TargetCenter), typeof(Location), typeof(MapBase),
|
2015-11-11 19:48:50 +01:00
|
|
|
|
new PropertyMetadata(new Location(), (o, e) => ((MapBase)o).TargetCenterPropertyChanged((Location)e.NewValue)));
|
2013-12-05 17:56:04 +01:00
|
|
|
|
|
|
|
|
|
|
public static readonly DependencyProperty ZoomLevelProperty = DependencyProperty.Register(
|
2017-06-25 23:05:48 +02:00
|
|
|
|
nameof(ZoomLevel), typeof(double), typeof(MapBase),
|
2015-11-11 19:48:50 +01:00
|
|
|
|
new PropertyMetadata(1d, (o, e) => ((MapBase)o).ZoomLevelPropertyChanged((double)e.NewValue)));
|
2013-12-05 17:56:04 +01:00
|
|
|
|
|
|
|
|
|
|
public static readonly DependencyProperty TargetZoomLevelProperty = DependencyProperty.Register(
|
2017-06-25 23:05:48 +02:00
|
|
|
|
nameof(TargetZoomLevel), typeof(double), typeof(MapBase),
|
2015-11-11 19:48:50 +01:00
|
|
|
|
new PropertyMetadata(1d, (o, e) => ((MapBase)o).TargetZoomLevelPropertyChanged((double)e.NewValue)));
|
2013-12-05 17:56:04 +01:00
|
|
|
|
|
|
|
|
|
|
public static readonly DependencyProperty HeadingProperty = DependencyProperty.Register(
|
2017-06-25 23:05:48 +02:00
|
|
|
|
nameof(Heading), typeof(double), typeof(MapBase),
|
2015-11-11 19:48:50 +01:00
|
|
|
|
new PropertyMetadata(0d, (o, e) => ((MapBase)o).HeadingPropertyChanged((double)e.NewValue)));
|
2013-12-05 17:56:04 +01:00
|
|
|
|
|
|
|
|
|
|
public static readonly DependencyProperty TargetHeadingProperty = DependencyProperty.Register(
|
2017-06-25 23:05:48 +02:00
|
|
|
|
nameof(TargetHeading), typeof(double), typeof(MapBase),
|
2015-11-11 19:48:50 +01:00
|
|
|
|
new PropertyMetadata(0d, (o, e) => ((MapBase)o).TargetHeadingPropertyChanged((double)e.NewValue)));
|
2013-12-05 17:56:04 +01:00
|
|
|
|
|
2020-03-28 21:53:38 +01:00
|
|
|
|
public static readonly DependencyProperty ViewScaleProperty = DependencyProperty.Register(
|
|
|
|
|
|
nameof(ViewScale), typeof(double), typeof(MapBase), new PropertyMetadata(0d));
|
|
|
|
|
|
|
2018-03-11 21:03:44 +01:00
|
|
|
|
internal static readonly DependencyProperty CenterPointProperty = DependencyProperty.Register(
|
|
|
|
|
|
"CenterPoint", typeof(Windows.Foundation.Point), typeof(MapBase),
|
|
|
|
|
|
new PropertyMetadata(new Windows.Foundation.Point(), (o, e) => ((MapBase)o).CenterPointPropertyChanged((Windows.Foundation.Point)e.NewValue)));
|
|
|
|
|
|
|
2017-09-05 20:57:17 +02:00
|
|
|
|
public MapBase()
|
2012-11-22 21:42:29 +01:00
|
|
|
|
{
|
2017-06-25 23:05:48 +02:00
|
|
|
|
// set Background by Style to enable resetting by ClearValue in MapLayerPropertyChanged
|
2014-11-19 21:11:14 +01:00
|
|
|
|
var style = new Style(typeof(MapBase));
|
2016-08-08 20:36:02 +02:00
|
|
|
|
style.Setters.Add(new Setter(BackgroundProperty, new SolidColorBrush(Colors.Transparent)));
|
2014-11-19 21:11:14 +01:00
|
|
|
|
Style = style;
|
|
|
|
|
|
|
2015-08-25 20:04:33 +02:00
|
|
|
|
SizeChanged += (s, e) =>
|
|
|
|
|
|
{
|
2017-10-07 17:43:28 +02:00
|
|
|
|
Clip = new RectangleGeometry
|
|
|
|
|
|
{
|
|
|
|
|
|
Rect = new Rect(0d, 0d, e.NewSize.Width, e.NewSize.Height)
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2017-09-05 20:57:17 +02:00
|
|
|
|
ResetTransformCenter();
|
|
|
|
|
|
UpdateTransform();
|
2015-08-25 20:04:33 +02:00
|
|
|
|
};
|
2012-11-22 21:42:29 +01:00
|
|
|
|
}
|
2018-03-11 21:03:44 +01:00
|
|
|
|
|
2020-03-28 21:53:38 +01:00
|
|
|
|
private void SetViewScale(double scale)
|
|
|
|
|
|
{
|
|
|
|
|
|
SetValue(ViewScaleProperty, scale);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-03-11 21:03:44 +01:00
|
|
|
|
private void CenterPointPropertyChanged(Windows.Foundation.Point center)
|
|
|
|
|
|
{
|
|
|
|
|
|
CenterPointPropertyChanged(new Location(center.Y, center.X));
|
|
|
|
|
|
}
|
2012-11-22 21:42:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|