Restore MapBase.ViewScale property

This commit is contained in:
ClemensFischer 2022-11-02 19:49:18 +01:00
parent 10f89b0da9
commit 14c26b34e8
3 changed files with 26 additions and 0 deletions

View file

@ -215,6 +215,12 @@ namespace MapControl
set => SetValue(AnimationEasingFunctionProperty, value); set => SetValue(AnimationEasingFunctionProperty, value);
} }
/// <summary>
/// Gets the scaling factor from cartesian map coordinates to view coordinates,
/// i.e. pixels per meter, as a read-only dependency property.
/// </summary>
public double ViewScale => (double)GetValue(ViewScaleProperty);
/// <summary> /// <summary>
/// Gets the ViewTransform instance that is used to transform between cartesian map coordinates /// Gets the ViewTransform instance that is used to transform between cartesian map coordinates
/// and view coordinates. /// and view coordinates.
@ -770,6 +776,8 @@ namespace MapControl
} }
} }
SetViewScale(ViewTransform.Scale);
OnViewportChanged(new ViewportChangedEventArgs(projectionChanged, Center.Longitude - centerLongitude)); OnViewportChanged(new ViewportChangedEventArgs(projectionChanged, Center.Longitude - centerLongitude));
centerLongitude = Center.Longitude; centerLongitude = Center.Longitude;

View file

@ -42,6 +42,11 @@ namespace MapControl
0d, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, 0d, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault,
(o, e) => ((MapBase)o).TargetHeadingPropertyChanged((double)e.NewValue))); (o, e) => ((MapBase)o).TargetHeadingPropertyChanged((double)e.NewValue)));
private static readonly DependencyPropertyKey ViewScalePropertyKey = DependencyProperty.RegisterReadOnly(
nameof(ViewScale), typeof(double), typeof(MapBase), new PropertyMetadata(0d));
public static readonly DependencyProperty ViewScaleProperty = ViewScalePropertyKey.DependencyProperty;
private static readonly DependencyProperty CenterPointProperty = DependencyProperty.Register( private static readonly DependencyProperty CenterPointProperty = DependencyProperty.Register(
"CenterPoint", typeof(Point), typeof(MapBase), new PropertyMetadata(new Point(), "CenterPoint", typeof(Point), typeof(MapBase), new PropertyMetadata(new Point(),
(o, e) => (o, e) =>
@ -63,5 +68,10 @@ namespace MapControl
ResetTransformCenter(); ResetTransformCenter();
UpdateTransform(); UpdateTransform();
} }
private void SetViewScale(double scale)
{
SetValue(ViewScalePropertyKey, scale);
}
} }
} }

View file

@ -43,6 +43,9 @@ namespace MapControl
nameof(TargetHeading), typeof(double), typeof(MapBase), nameof(TargetHeading), typeof(double), typeof(MapBase),
new PropertyMetadata(0d, (o, e) => ((MapBase)o).TargetHeadingPropertyChanged((double)e.NewValue))); new PropertyMetadata(0d, (o, e) => ((MapBase)o).TargetHeadingPropertyChanged((double)e.NewValue)));
public static readonly DependencyProperty ViewScaleProperty = DependencyProperty.Register(
nameof(ViewScale), typeof(double), typeof(MapBase), new PropertyMetadata(0d));
internal static readonly DependencyProperty CenterPointProperty = DependencyProperty.Register( internal static readonly DependencyProperty CenterPointProperty = DependencyProperty.Register(
"CenterPoint", typeof(Windows.Foundation.Point), typeof(MapBase), "CenterPoint", typeof(Windows.Foundation.Point), typeof(MapBase),
new PropertyMetadata(new Windows.Foundation.Point(), (o, e) => new PropertyMetadata(new Windows.Foundation.Point(), (o, e) =>
@ -71,5 +74,10 @@ namespace MapControl
ResetTransformCenter(); ResetTransformCenter();
UpdateTransform(); UpdateTransform();
} }
private void SetViewScale(double scale)
{
SetValue(ViewScaleProperty, scale);
}
} }
} }