diff --git a/GMap.NET.Core/GMap.NET.Internals/Core.cs b/GMap.NET.Core/GMap.NET.Internals/Core.cs
index 74bc9a24..10b493a0 100644
--- a/GMap.NET.Core/GMap.NET.Internals/Core.cs
+++ b/GMap.NET.Core/GMap.NET.Internals/Core.cs
@@ -35,6 +35,7 @@ internal class Core : IDisposable
public GPoint mouseLastZoom;
public MouseWheelZoomType MouseWheelZoomType = MouseWheelZoomType.MousePositionAndCenter;
+ public bool MouseWheelZoomEnabled = true;
public PointLatLng? LastLocationInBounds = null;
public bool VirtualSizeEnabled = false;
diff --git a/GMap.NET.WindowsForms/GMap.NET.WindowsForms/GMapControl.cs b/GMap.NET.WindowsForms/GMap.NET.WindowsForms/GMapControl.cs
index 02467c1a..adc9c6f7 100644
--- a/GMap.NET.WindowsForms/GMap.NET.WindowsForms/GMapControl.cs
+++ b/GMap.NET.WindowsForms/GMap.NET.WindowsForms/GMapControl.cs
@@ -137,6 +137,23 @@ public MouseWheelZoomType MouseWheelZoomType
}
}
+ ///
+ /// enable map zoom on mouse wheel
+ ///
+ [Category("GMap.NET")]
+ [Description("enable map zoom on mouse wheel")]
+ public bool MouseWheelZoomEnabled
+ {
+ get
+ {
+ return Core.MouseWheelZoomEnabled;
+ }
+ set
+ {
+ Core.MouseWheelZoomEnabled = value;
+ }
+ }
+
///
/// text on empty tiles
///
@@ -2295,65 +2312,68 @@ protected override void OnMouseLeave(EventArgs e)
protected override void OnMouseWheel(MouseEventArgs e)
{
- base.OnMouseWheel(e);
+ base.OnMouseWheel(e);
- if(mouseIn && (!IsMouseOverMarker || IgnoreMarkerOnMouseWheel) && !Core.IsDragging)
+ if (MouseWheelZoomEnabled)
{
- if(Core.mouseLastZoom.X != e.X && Core.mouseLastZoom.Y != e.Y)
- {
- if(MouseWheelZoomType == MouseWheelZoomType.MousePositionAndCenter)
- {
- Core.position = FromLocalToLatLng(e.X, e.Y);
- }
- else if(MouseWheelZoomType == MouseWheelZoomType.ViewCenter)
- {
- Core.position = FromLocalToLatLng((int)Width / 2, (int)Height / 2);
- }
- else if(MouseWheelZoomType == MouseWheelZoomType.MousePositionWithoutCenter)
- {
- Core.position = FromLocalToLatLng(e.X, e.Y);
- }
+ if (mouseIn && (!IsMouseOverMarker || IgnoreMarkerOnMouseWheel) && !Core.IsDragging)
+ {
+ if (Core.mouseLastZoom.X != e.X && Core.mouseLastZoom.Y != e.Y)
+ {
+ if (MouseWheelZoomType == MouseWheelZoomType.MousePositionAndCenter)
+ {
+ Core.position = FromLocalToLatLng(e.X, e.Y);
+ }
+ else if (MouseWheelZoomType == MouseWheelZoomType.ViewCenter)
+ {
+ Core.position = FromLocalToLatLng((int)Width / 2, (int)Height / 2);
+ }
+ else if (MouseWheelZoomType == MouseWheelZoomType.MousePositionWithoutCenter)
+ {
+ Core.position = FromLocalToLatLng(e.X, e.Y);
+ }
- Core.mouseLastZoom.X = e.X;
- Core.mouseLastZoom.Y = e.Y;
- }
+ Core.mouseLastZoom.X = e.X;
+ Core.mouseLastZoom.Y = e.Y;
+ }
- // set mouse position to map center
- if(MouseWheelZoomType != MouseWheelZoomType.MousePositionWithoutCenter)
- {
- if(!GMaps.Instance.IsRunningOnMono)
- {
- System.Drawing.Point p = PointToScreen(new System.Drawing.Point(Width / 2, Height / 2));
- Stuff.SetCursorPos((int)p.X, (int)p.Y);
- }
- }
+ // set mouse position to map center
+ if (MouseWheelZoomType != MouseWheelZoomType.MousePositionWithoutCenter)
+ {
+ if (!GMaps.Instance.IsRunningOnMono)
+ {
+ System.Drawing.Point p = PointToScreen(new System.Drawing.Point(Width / 2, Height / 2));
+ Stuff.SetCursorPos((int)p.X, (int)p.Y);
+ }
+ }
- Core.MouseWheelZooming = true;
+ Core.MouseWheelZooming = true;
- if(e.Delta > 0)
- {
- if(!InvertedMouseWheelZooming)
- {
- Zoom = ((int)Zoom) + 1;
- }
- else
- {
- Zoom = ((int)(Zoom + 0.99)) - 1;
- }
- }
- else if(e.Delta < 0)
- {
- if(!InvertedMouseWheelZooming)
- {
- Zoom = ((int)(Zoom + 0.99)) - 1;
- }
- else
- {
- Zoom = ((int)Zoom) + 1;
- }
- }
+ if (e.Delta > 0)
+ {
+ if (!InvertedMouseWheelZooming)
+ {
+ Zoom = ((int)Zoom) + 1;
+ }
+ else
+ {
+ Zoom = ((int)(Zoom + 0.99)) - 1;
+ }
+ }
+ else if (e.Delta < 0)
+ {
+ if (!InvertedMouseWheelZooming)
+ {
+ Zoom = ((int)(Zoom + 0.99)) - 1;
+ }
+ else
+ {
+ Zoom = ((int)Zoom) + 1;
+ }
+ }
- Core.MouseWheelZooming = false;
+ Core.MouseWheelZooming = false;
+ }
}
}
#endif