Skip to content

Commit 49e9212

Browse files
fix: align GestureSettings (#28)
* Update hardcoded false with settings values * - align GestureSettings --------- Co-authored-by: Tuyen Vu <tuyen.vuduc0902@gmail.com>
1 parent a75786b commit 49e9212

File tree

5 files changed

+121
-58
lines changed

5 files changed

+121
-58
lines changed

README.md

+27
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,33 @@ NOTE: A handy command to generate a new example
117117
dotnet cake -- --name SymbolClustering --index 58 --group Annotations --title "Add Cluster Symbol Annotations" --subtitle "Show fire hydrants in Washington DC area in a cluster using a symbol layer."
118118
````
119119
120+
# Features
121+
122+
## GestureSettings
123+
124+
|#|Android|iOS|Aligned|
125+
|----|----|----|----|
126+
|1|rotateEnabled| rotateEnabled | YES |
127+
|2|scrollEnabled| panEnabled | NOPE |
128+
|3|scrollMode| panMode | NOPE |
129+
|4|simultaneousRotateAndPinchToZoomEnabled| simultaneousRotateAndPinchZoomEnabled | NOPE |
130+
|5|doubleTouchToZoomOutEnabled| doubleTouchToZoomOutEnabled | YES |
131+
|6|doubleTapToZoomInEnabled| doubleTapToZoomInEnabled | YES |
132+
|7|focalPoint|focalPoint| YES |
133+
|8|pitchEnabled|pitchEnabled| YES |
134+
|9|quickZoomEnabled|quickZoomEnabled| YES |
135+
|10|pinchScrollEnabled|pinchScrollEnabled| YES |
136+
|11|pinchToZoomEnabled| N/A | NOPE, pinchEnabled & pinchZoomEnabled |
137+
|12|pinchToZoomDecelerationEnabled| N/A | NOPE |
138+
|13|rotateDecelerationEnabled | N/A | NOPE |
139+
|14|scrollDecelerationEnabled| N/A | NOPE |
140+
|15|increaseRotateThresholdWhenPinchingToZoom | N/A | NOPE |
141+
|16|increasePinchToZoomThresholdWhenRotating| N/A | NOPE |
142+
|17|zoomAnimationAmount| N/A | NOPE |
143+
|18| N/A |pinchEnabled| NOPE |
144+
|19| N/A |pinchZoomEnabled| NOPE |
145+
|20| N/A |panDecelerationFactor| NOPE |
146+
120147
# NOTES
121148
122149
1) Failed to delete `.gradle` folder

src/libs/Mapbox.Maui/Models/GestureSettings.cs

+69-42
Original file line numberDiff line numberDiff line change
@@ -7,96 +7,123 @@ public GestureSettings()
77
}
88

99
/// <summary>
10-
/// Whether the rotate gesture is enabled.
10+
/// Whether double tapping the map with one touch results in a zoom-in animation.
1111
/// </summary>
12-
public bool RotateEnabled { get; set; } = true;
12+
public bool DoubleTapToZoomInEnabled { get; set; } = true;
1313
/// <summary>
14-
/// Whether the pinch to zoom gesture is enabled.
15-
///
16-
/// iOS: PinchZoomEnabled
14+
/// Whether single tapping the map with two touches results in a zoom-out animation.
1715
/// </summary>
18-
public bool PinchToZoomEnabled { get; set; } = true;
16+
public bool DoubleTouchToZoomOutEnabled { get; set; } = true;
1917
/// <summary>
20-
/// Whether the single-touch scroll gesture is enabled.
18+
/// By default, gestures rotate and zoom around the center of the gesture. Set this property to
19+
/// rotate and zoom around a fixed point instead.
2120
/// </summary>
22-
public bool ScrollEnabled { get; set; } = true;
21+
public ScreenPosition? FocalPoint { get; set; }
2322
/// <summary>
24-
/// Whether rotation is enabled for the pinch to zoom gesture.
25-
///
26-
/// iOS: SimultaneousRotateAndPinchZoomEnabled
23+
/// Whether the quick zoom gesture is enabled.
2724
/// </summary>
28-
public bool SimultaneousRotateAndPinchToZoomEnabled { get; set; } = true;
25+
public bool QuickZoomEnabled { get; set; } = true;
2926
/// <summary>
3027
/// Whether the pitch gesture is enabled.
3128
/// </summary>
3229
public bool PitchEnabled { get; set; } = true;
3330
/// <summary>
31+
/// Whether pan is enabled for the pinch gesture.
32+
///
33+
/// iOS: PinchPanEnabled
34+
/// </summary>
35+
public bool PinchScrollEnabled { get; set; } = true;
36+
/// <summary>
37+
/// Whether the rotate gesture is enabled.
38+
/// </summary>
39+
public bool RotateEnabled { get; set; } = true;
40+
/// <summary>
41+
/// Whether the single-touch scroll gesture is enabled.
42+
///
43+
/// iOS: PanEnabled
44+
/// </summary>
45+
public bool ScrollEnabled { get; set; } = true;
46+
/// <summary>
3447
/// Configures the directions in which the map is allowed to move during a scroll gesture.
3548
///
3649
/// iOS: PanMode
3750
/// </summary>
3851
public PanMode ScrollMode { get; set; } = PanMode.Both;
3952
/// <summary>
40-
/// Whether double tapping the map with one touch results in a zoom-in animation.
53+
/// Whether rotation is enabled for the pinch to zoom gesture.
54+
///
55+
/// iOS: SimultaneousRotateAndPinchZoomEnabled
4156
/// </summary>
42-
public bool DoubleTapToZoomInEnabled { get; set; } = true;
57+
public bool SimultaneousRotateAndPinchToZoomEnabled { get; set; } = true;
58+
4359
/// <summary>
44-
/// Whether single tapping the map with two touches results in a zoom-out animation.
60+
/// Android only.
61+
///
62+
/// Whether rotate threshold increases when pinching to zoom. true by default.
4563
/// </summary>
46-
public bool DoubleTouchToZoomOutEnabled { get; set; } = true;
64+
public bool IncreaseRotateThresholdWhenPinchingToZoom { get; set; } = true;
4765
/// <summary>
48-
/// Whether the quick zoom gesture is enabled.
66+
/// Android only.
67+
/// Whether pinch to zoom threshold increases when rotating. true by default.
4968
/// </summary>
50-
public bool QuickZoomEnabled { get; set; } = true;
69+
public bool IncreasePinchToZoomThresholdWhenRotating { get; set; } = true;
5170
/// <summary>
52-
/// By default, gestures rotate and zoom around the center of the gesture. Set this property to
53-
/// rotate and zoom around a fixed point instead.
71+
/// iOS only.
72+
///
73+
/// A constant factor that determines how quickly pan deceleration animations happen.
74+
/// Multiplied with the velocity vector once per millisecond during deceleration animations.
5475
/// </summary>
55-
public ScreenPosition? FocalPoint { get; set; }
76+
public float? PanDecelerationFactor { get; set; }
5677
/// <summary>
5778
/// Android only.
79+
///
5880
/// Whether a deceleration animation following a pinch-to-zoom gesture is enabled. True by default.
5981
/// </summary>
6082
public bool PinchToZoomDecelerationEnabled { get; set; } = true;
6183
/// <summary>
6284
/// Android only.
63-
/// Whether a deceleration animation following a rotate gesture is enabled. True by default.
85+
///
86+
/// Whether the pinch to zoom gesture is enabled.
6487
/// </summary>
65-
public bool RotateDecelerationEnabled { get; set; } = true;
88+
public bool PinchToZoomEnabled
89+
{
90+
get => PinchEnabled && PinchZoomEnabled;
91+
set
92+
{
93+
PinchEnabled = PinchZoomEnabled = value;
94+
}
95+
}
6696
/// <summary>
67-
/// Android only.
68-
/// Whether a deceleration animation following a scroll gesture is enabled. True by default.
97+
/// iOS Only
98+
///
99+
/// Whether the pinch gesture is enabled.
69100
/// </summary>
70-
public bool ScrollDecelerationEnabled { get; set; } = true;
101+
public bool PinchEnabled { get; set; } = true;
102+
/// <summary>
103+
/// iOS Only
104+
///
105+
/// Whether zoom is enabled for the pinch gesture.
106+
/// </summary>
107+
public bool PinchZoomEnabled { get; set; } = true;
71108
/// <summary>
72109
/// Android only.
73110
///
74-
/// Whether rotate threshold increases when pinching to zoom. true by default.
111+
/// Whether a deceleration animation following a rotate gesture is enabled. True by default.
75112
/// </summary>
76-
public bool IncreaseRotateThresholdWhenPinchingToZoom { get; set; } = true;
113+
public bool RotateDecelerationEnabled { get; set; } = true;
77114
/// <summary>
78115
/// Android only.
79-
/// Whether pinch to zoom threshold increases when rotating. true by default.
116+
///
117+
/// Whether a deceleration animation following a scroll gesture is enabled. True by default.
80118
/// </summary>
81-
public bool IncreasePinchToZoomThresholdWhenRotating { get; set; } = true;
119+
public bool ScrollDecelerationEnabled { get; set; } = true;
82120
/// <summary>
83121
/// Android only.
122+
///
84123
/// The amount by which the zoom level increases or decreases during a double-tap-to-zoom-in or
85124
/// double-touch-to-zoom-out gesture. 1.0 by default. Must be positive.
86125
/// </summary>
87126
public float ZoomAnimationAmount { get; set; } = 1.0f;
88-
/// <summary>
89-
/// iOS only.
90-
/// A constant factor that determines how quickly pan deceleration animations happen.
91-
/// Multiplied with the velocity vector once per millisecond during deceleration animations.
92-
/// </summary>
93-
public float PanDecelerationFactor { get; set; } = 1.0f;
94-
/// <summary>
95-
/// Whether pan is enabled for the pinch gesture.
96-
///
97-
/// iOS: PanEnabled
98-
/// </summary>
99-
public bool PinchScrollEnabled { get; set; } = true;
100127
}
101128
public enum PanMode
102129
{

src/libs/Mapbox.Maui/Platforms/Android/MapboxViewHandler.cs

+9-7
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,21 @@ private static void HandleGestureSettingsChanged(MapboxViewHandler handler, IMap
2525
gestures.DoubleTapToZoomInEnabled = view.GestureSettings.DoubleTapToZoomInEnabled;
2626
gestures.DoubleTouchToZoomOutEnabled = view.GestureSettings.DoubleTouchToZoomOutEnabled;
2727
gestures.FocalPoint = view.GestureSettings.FocalPoint?.ToScreenCoordinate();
28+
gestures.QuickZoomEnabled = view.GestureSettings.QuickZoomEnabled;
29+
gestures.PitchEnabled = view.GestureSettings.PitchEnabled;
30+
gestures.PinchScrollEnabled = view.GestureSettings.PinchScrollEnabled;
31+
gestures.RotateEnabled = view.GestureSettings.RotateEnabled;
32+
gestures.ScrollEnabled = view.GestureSettings.ScrollEnabled;
33+
gestures.ScrollMode = view.GestureSettings.ScrollMode.ToNative();
34+
gestures.SimultaneousRotateAndPinchToZoomEnabled = view.GestureSettings.SimultaneousRotateAndPinchToZoomEnabled;
35+
36+
// Android only
2837
gestures.IncreasePinchToZoomThresholdWhenRotating = view.GestureSettings.IncreasePinchToZoomThresholdWhenRotating;
2938
gestures.IncreaseRotateThresholdWhenPinchingToZoom = view.GestureSettings.IncreaseRotateThresholdWhenPinchingToZoom;
30-
gestures.PinchScrollEnabled = view.GestureSettings.PinchScrollEnabled;
3139
gestures.PinchToZoomDecelerationEnabled = view.GestureSettings.PinchToZoomDecelerationEnabled;
3240
gestures.PinchToZoomEnabled = view.GestureSettings.PinchToZoomEnabled;
33-
gestures.PitchEnabled = view.GestureSettings.PitchEnabled;
34-
gestures.QuickZoomEnabled = view.GestureSettings.QuickZoomEnabled;
3541
gestures.RotateDecelerationEnabled = view.GestureSettings.RotateDecelerationEnabled;
36-
gestures.RotateEnabled = view.GestureSettings.RotateEnabled;
3742
gestures.ScrollDecelerationEnabled = view.GestureSettings.ScrollDecelerationEnabled;
38-
gestures.ScrollEnabled = view.GestureSettings.ScrollEnabled;
39-
gestures.ScrollMode = view.GestureSettings.ScrollMode.ToNative();
40-
gestures.SimultaneousRotateAndPinchToZoomEnabled = view.GestureSettings.SimultaneousRotateAndPinchToZoomEnabled;
4143
gestures.ZoomAnimationAmount = view.GestureSettings.ZoomAnimationAmount;
4244
}
4345

src/libs/Mapbox.Maui/Platforms/iOS/MapboxViewHandler.cs

+12-9
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,22 @@ private static void HandleGestureSettingsChanged(MapboxViewHandler handler, IMap
2020
if (mapView == null) return;
2121

2222
var gestureOptions = new TMBGestureOptions(
23-
panEnabled: view.GestureSettings.PinchScrollEnabled,
24-
pinchEnabled: false,
25-
rotateEnabled: view.GestureSettings.RotateEnabled,
26-
simultaneousRotateAndPinchZoomEnabled: view.GestureSettings.SimultaneousRotateAndPinchToZoomEnabled,
27-
pinchZoomEnabled: view.GestureSettings.PinchToZoomEnabled,
28-
pinchPanEnabled: false,
29-
pitchEnabled: view.GestureSettings.PitchEnabled,
3023
doubleTapToZoomInEnabled: view.GestureSettings.DoubleTapToZoomInEnabled,
3124
doubleTouchToZoomOutEnabled: view.GestureSettings.DoubleTouchToZoomOutEnabled,
25+
focalPoint: view.GestureSettings.FocalPoint?.ToNSValue(),
3226
quickZoomEnabled: view.GestureSettings.QuickZoomEnabled,
33-
panDecelerationFactor: UIScrollView.DecelerationRateNormal,
27+
pitchEnabled: view.GestureSettings.PitchEnabled,
28+
pinchPanEnabled: view.GestureSettings.PinchScrollEnabled,
29+
rotateEnabled: view.GestureSettings.RotateEnabled,
30+
panEnabled: view.GestureSettings.ScrollEnabled,
3431
panMode: view.GestureSettings.ScrollMode.ToNative(),
35-
focalPoint: view.GestureSettings.FocalPoint?.ToNSValue()
32+
simultaneousRotateAndPinchZoomEnabled: view.GestureSettings.SimultaneousRotateAndPinchToZoomEnabled,
33+
34+
// iOS Only
35+
panDecelerationFactor: view.GestureSettings.PanDecelerationFactor
36+
?? UIScrollView.DecelerationRateNormal,
37+
pinchEnabled: view.GestureSettings.PinchEnabled,
38+
pinchZoomEnabled: view.GestureSettings.PinchZoomEnabled
3639
);
3740
mapView.Gestures().GestureOptions = gestureOptions;
3841
}

src/qs/MapboxMauiQs/Examples/Lab/67.AddRemoveAnnotations/AddRemoveAnnotationsExample.cs

+4
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ private async void RemoveAnnotation()
121121
case PointAnnotation pointAnnotation:
122122
pointAnnotationManager.RemoveAnnotations(pointAnnotation.Id);
123123
break;
124+
case CircleAnnotation circleAnnotation:
125+
circleAnnotationManager.RemoveAnnotations(circleAnnotation.Id);
126+
break;
124127
}
125128

126129
await DisplayAlert("Info", $"Last {annotation.GetType().Name} was removed", "OK");
@@ -143,6 +146,7 @@ private async void RemoveAnnotation()
143146
private async void RemoveAllAnnotations()
144147
{
145148
pointAnnotationManager.RemoveAllAnnotations();
149+
circleAnnotationManager.RemoveAllAnnotations();
146150
await DisplayAlert("Info", $"All annotations were removed", "OK");
147151
annotations.Clear();
148152
map.CameraController.EaseTo(new CameraOptions

0 commit comments

Comments
 (0)