diff --git a/MapControl/Shared/MapTileLayerBase.cs b/MapControl/Shared/MapTileLayerBase.cs
index cfad25d6..a9c42f86 100644
--- a/MapControl/Shared/MapTileLayerBase.cs
+++ b/MapControl/Shared/MapTileLayerBase.cs
@@ -52,7 +52,7 @@ namespace MapControl
new PropertyMetadata(TimeSpan.FromSeconds(0.2), (o, e) => ((MapTileLayerBase)o).updateTimer.Interval = (TimeSpan)e.NewValue));
public static readonly DependencyProperty UpdateWhileViewportChangingProperty = DependencyProperty.Register(
- nameof(UpdateWhileViewportChanging), typeof(bool), typeof(MapTileLayerBase), new PropertyMetadata(true));
+ nameof(UpdateWhileViewportChanging), typeof(bool), typeof(MapTileLayerBase), new PropertyMetadata(false));
public static readonly DependencyProperty MapBackgroundProperty = DependencyProperty.Register(
nameof(MapBackground), typeof(Brush), typeof(MapTileLayerBase), new PropertyMetadata(null));
diff --git a/MapControl/WPF/Map.WPF.cs b/MapControl/WPF/Map.WPF.cs
index 42363983..4736b79f 100644
--- a/MapControl/WPF/Map.WPF.cs
+++ b/MapControl/WPF/Map.WPF.cs
@@ -14,13 +14,14 @@ namespace MapControl
public class Map : MapBase
{
public static readonly DependencyProperty MouseWheelZoomDeltaProperty = DependencyProperty.Register(
- nameof(MouseWheelZoomDelta), typeof(double), typeof(Map), new PropertyMetadata(1d));
+ nameof(MouseWheelZoomDelta), typeof(double), typeof(Map), new PropertyMetadata(0.25));
public static readonly DependencyProperty ManipulationModeProperty = DependencyProperty.Register(
nameof(ManipulationMode), typeof(ManipulationModes), typeof(Map),
new PropertyMetadata(ManipulationModes.Scale | ManipulationModes.Translate));
private Point? mousePosition;
+ private double mouseWheelDelta;
static Map()
{
@@ -38,8 +39,8 @@ namespace MapControl
}
///
- /// Gets or sets the amount by which the ZoomLevel property changes during a MouseWheel event.
- /// The default value is 1.
+ /// Gets or sets the amount by which the ZoomLevel property changes by a MouseWheel event.
+ /// The default value is 0.25.
///
public double MouseWheelZoomDelta
{
@@ -100,9 +101,17 @@ namespace MapControl
private void OnMouseWheel(object sender, MouseWheelEventArgs e)
{
- var zoomLevel = TargetZoomLevel + MouseWheelZoomDelta * Math.Sign(e.Delta);
+ mouseWheelDelta += e.Delta / 120d; // standard mouse wheel delta
- ZoomMap(e.GetPosition(this), MouseWheelZoomDelta * Math.Round(zoomLevel / MouseWheelZoomDelta));
+ if (Math.Abs(mouseWheelDelta) >= 1d)
+ {
+ // Zoom to integer multiple of MouseWheelZoomDelta.
+
+ ZoomMap(e.GetPosition(this),
+ MouseWheelZoomDelta * Math.Round(TargetZoomLevel / MouseWheelZoomDelta + mouseWheelDelta));
+
+ mouseWheelDelta = 0d;
+ }
}
}
}
diff --git a/MapControl/WinUI/Map.WinUI.cs b/MapControl/WinUI/Map.WinUI.cs
index 0cdbc7a1..e08bf6e0 100644
--- a/MapControl/WinUI/Map.WinUI.cs
+++ b/MapControl/WinUI/Map.WinUI.cs
@@ -21,9 +21,10 @@ namespace MapControl
public class Map : MapBase
{
public static readonly DependencyProperty MouseWheelZoomDeltaProperty = DependencyProperty.Register(
- nameof(MouseWheelZoomDelta), typeof(double), typeof(Map), new PropertyMetadata(1d));
+ nameof(MouseWheelZoomDelta), typeof(double), typeof(Map), new PropertyMetadata(0.25));
private Point? mousePosition;
+ private double mouseWheelDelta;
public Map()
{
@@ -32,16 +33,16 @@ namespace MapControl
| ManipulationModes.TranslateY
| ManipulationModes.TranslateInertia;
- PointerWheelChanged += OnPointerWheelChanged;
+ ManipulationDelta += OnManipulationDelta;
PointerPressed += OnPointerPressed;
PointerReleased += OnPointerReleased;
PointerMoved += OnPointerMoved;
- ManipulationDelta += OnManipulationDelta;
+ PointerWheelChanged += OnPointerWheelChanged;
}
///
- /// Gets or sets the amount by which the ZoomLevel property changes during a MouseWheel event.
- /// The default value is 1.
+ /// Gets or sets the amount by which the ZoomLevel property changes by a PointerWheelChanged event.
+ /// The default value is 0.25.
///
public double MouseWheelZoomDelta
{
@@ -49,14 +50,11 @@ namespace MapControl
set => SetValue(MouseWheelZoomDeltaProperty, value);
}
- private void OnPointerWheelChanged(object sender, PointerRoutedEventArgs e)
+ private void OnManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
{
- if (e.Pointer.PointerDeviceType == PointerDeviceType.Mouse)
+ if (!mousePosition.HasValue)
{
- var point = e.GetCurrentPoint(this);
- var zoomLevel = TargetZoomLevel + MouseWheelZoomDelta * Math.Sign(point.Properties.MouseWheelDelta);
-
- ZoomMap(point.Position, MouseWheelZoomDelta * Math.Round(zoomLevel / MouseWheelZoomDelta));
+ TransformMap(e.Position, e.Delta.Translation, e.Delta.Rotation, e.Delta.Scale);
}
}
@@ -95,11 +93,23 @@ namespace MapControl
}
}
- private void OnManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
+ private void OnPointerWheelChanged(object sender, PointerRoutedEventArgs e)
{
- if (!mousePosition.HasValue)
+ if (e.Pointer.PointerDeviceType == PointerDeviceType.Mouse)
{
- TransformMap(e.Position, e.Delta.Translation, e.Delta.Rotation, e.Delta.Scale);
+ var point = e.GetCurrentPoint(this);
+
+ mouseWheelDelta += point.Properties.MouseWheelDelta / 120d; // standard mouse wheel delta
+
+ if (Math.Abs(mouseWheelDelta) >= 1d)
+ {
+ // Zoom to integer multiple of MouseWheelZoomDelta.
+
+ ZoomMap(point.Position,
+ MouseWheelZoomDelta * Math.Round(TargetZoomLevel / MouseWheelZoomDelta + mouseWheelDelta));
+
+ mouseWheelDelta = 0d;
+ }
}
}
}
diff --git a/SampleApps/WpfApplication/MainWindow.xaml b/SampleApps/WpfApplication/MainWindow.xaml
index 3af07971..18b2a8b2 100644
--- a/SampleApps/WpfApplication/MainWindow.xaml
+++ b/SampleApps/WpfApplication/MainWindow.xaml
@@ -114,7 +114,7 @@