@maplibre/maplibre-react-native 11.0.0-beta.28 → 11.0.0-beta.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -9,6 +9,9 @@ const float CENTER_Y_OFFSET_BASE = -0.5f;
|
|
|
9
9
|
|
|
10
10
|
@implementation MLRNPointAnnotation {
|
|
11
11
|
UITapGestureRecognizer *customViewTap;
|
|
12
|
+
// Finger-to-anchor offset to preserve the touch position relative to the annotation's anchor
|
|
13
|
+
CGPoint _dragFingerOffset;
|
|
14
|
+
BOOL _dragFingerOffsetCaptured;
|
|
12
15
|
}
|
|
13
16
|
|
|
14
17
|
- (id)init {
|
|
@@ -37,6 +40,11 @@ const float CENTER_Y_OFFSET_BASE = -0.5f;
|
|
|
37
40
|
}
|
|
38
41
|
|
|
39
42
|
- (void)reactSetFrame:(CGRect)frame {
|
|
43
|
+
// Skip frame updates while dragging
|
|
44
|
+
if (self.dragState != MLNAnnotationViewDragStateNone) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
40
48
|
if ([_map.annotations containsObject:self]) {
|
|
41
49
|
[_map removeAnnotation:self];
|
|
42
50
|
}
|
|
@@ -55,6 +63,36 @@ const float CENTER_Y_OFFSET_BASE = -0.5f;
|
|
|
55
63
|
[self _setCenterOffset:self.frame];
|
|
56
64
|
}
|
|
57
65
|
|
|
66
|
+
- (void)setCenter:(CGPoint)center {
|
|
67
|
+
// Reset drag offset tracking whenever we're not in a drag
|
|
68
|
+
if (self.dragState == MLNAnnotationViewDragStateNone) {
|
|
69
|
+
_dragFingerOffsetCaptured = NO;
|
|
70
|
+
[super setCenter:center];
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (_map != nil) {
|
|
75
|
+
CGPoint coordPoint = [_map convertCoordinate:self.coordinate toPointToView:_map];
|
|
76
|
+
|
|
77
|
+
// Reject map-redraw resets: MapLibre re-projects annotations from their
|
|
78
|
+
// coordinate on every redraw, snapping the view back mid-drag.
|
|
79
|
+
if (fabs(center.x - coordPoint.x) < 0.5 && fabs(center.y - coordPoint.y) < 0.5) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Capture the finger-to-anchor offset so the view doesn't snap its center
|
|
84
|
+
// to the touch point, preserving where the user grabbed relative to the anchor.
|
|
85
|
+
if (!_dragFingerOffsetCaptured) {
|
|
86
|
+
_dragFingerOffset = CGPointMake(center.x - coordPoint.x, center.y - coordPoint.y);
|
|
87
|
+
_dragFingerOffsetCaptured = YES;
|
|
88
|
+
}
|
|
89
|
+
center.x -= _dragFingerOffset.x;
|
|
90
|
+
center.y -= _dragFingerOffset.y;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
[super setCenter:center];
|
|
94
|
+
}
|
|
95
|
+
|
|
58
96
|
- (void)setMap:(MLNMapView *)map {
|
|
59
97
|
if (map == nil) {
|
|
60
98
|
[_map removeAnnotation:self];
|
|
@@ -151,6 +189,7 @@ const float CENTER_Y_OFFSET_BASE = -0.5f;
|
|
|
151
189
|
}
|
|
152
190
|
}
|
|
153
191
|
[self addGestureRecognizer:customViewTap];
|
|
192
|
+
self.annotation = self;
|
|
154
193
|
return self;
|
|
155
194
|
}
|
|
156
195
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maplibre/maplibre-react-native",
|
|
3
3
|
"description": "React Native library for creating maps with MapLibre Native for Android & iOS",
|
|
4
|
-
"version": "11.0.0-beta.
|
|
4
|
+
"version": "11.0.0-beta.29",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
7
7
|
"provenance": true
|