mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
68 lines
3.3 KiB
C#
68 lines
3.3 KiB
C#
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
|
// © 2018 Clemens Fischer
|
|
// Licensed under the Microsoft Public License (Ms-PL)
|
|
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Media;
|
|
|
|
namespace MapControl
|
|
{
|
|
public partial class MapBase
|
|
{
|
|
public static readonly DependencyProperty ForegroundProperty =
|
|
Control.ForegroundProperty.AddOwner(typeof(MapBase));
|
|
|
|
public static readonly DependencyProperty CenterProperty = DependencyProperty.Register(
|
|
nameof(Center), typeof(Location), typeof(MapBase), new FrameworkPropertyMetadata(
|
|
new Location(), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault,
|
|
(o, e) => ((MapBase)o).CenterPropertyChanged((Location)e.NewValue)));
|
|
|
|
public static readonly DependencyProperty TargetCenterProperty = DependencyProperty.Register(
|
|
nameof(TargetCenter), typeof(Location), typeof(MapBase), new FrameworkPropertyMetadata(
|
|
new Location(), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault,
|
|
(o, e) => ((MapBase)o).TargetCenterPropertyChanged((Location)e.NewValue)));
|
|
|
|
public static readonly DependencyProperty ZoomLevelProperty = DependencyProperty.Register(
|
|
nameof(ZoomLevel), typeof(double), typeof(MapBase), new FrameworkPropertyMetadata(
|
|
1d, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault,
|
|
(o, e) => ((MapBase)o).ZoomLevelPropertyChanged((double)e.NewValue)));
|
|
|
|
public static readonly DependencyProperty TargetZoomLevelProperty = DependencyProperty.Register(
|
|
nameof(TargetZoomLevel), typeof(double), typeof(MapBase), new FrameworkPropertyMetadata(
|
|
1d, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault,
|
|
(o, e) => ((MapBase)o).TargetZoomLevelPropertyChanged((double)e.NewValue)));
|
|
|
|
public static readonly DependencyProperty HeadingProperty = DependencyProperty.Register(
|
|
nameof(Heading), typeof(double), typeof(MapBase), new FrameworkPropertyMetadata(
|
|
0d, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault,
|
|
(o, e) => ((MapBase)o).HeadingPropertyChanged((double)e.NewValue)));
|
|
|
|
public static readonly DependencyProperty TargetHeadingProperty = DependencyProperty.Register(
|
|
nameof(TargetHeading), typeof(double), typeof(MapBase), new FrameworkPropertyMetadata(
|
|
0d, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault,
|
|
(o, e) => ((MapBase)o).TargetHeadingPropertyChanged((double)e.NewValue)));
|
|
|
|
static MapBase()
|
|
{
|
|
ClipToBoundsProperty.OverrideMetadata(typeof(MapBase), new FrameworkPropertyMetadata(true));
|
|
BackgroundProperty.OverrideMetadata(typeof(MapBase), new FrameworkPropertyMetadata(Brushes.Transparent));
|
|
}
|
|
|
|
public MapBase()
|
|
{
|
|
MapProjection = new WebMercatorProjection();
|
|
ScaleRotateTransform.Children.Add(ScaleTransform);
|
|
ScaleRotateTransform.Children.Add(RotateTransform);
|
|
}
|
|
|
|
protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)
|
|
{
|
|
base.OnRenderSizeChanged(sizeInfo);
|
|
|
|
ResetTransformCenter();
|
|
UpdateTransform();
|
|
}
|
|
}
|
|
}
|