@maplibre/maplibre-react-native 11.0.0-alpha.42 → 11.0.0-alpha.43

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.
Files changed (137) hide show
  1. package/android/build.gradle +1 -3
  2. package/android/src/main/java/org/maplibre/reactnative/MLRNPackage.kt +3 -3
  3. package/android/src/main/java/org/maplibre/reactnative/components/annotations/callout/MLRNCallout.kt +7 -0
  4. package/android/src/main/java/org/maplibre/reactnative/components/annotations/callout/MLRNCalloutManager.kt +29 -0
  5. package/android/src/main/java/org/maplibre/reactnative/components/annotations/markerview/MLRNMarkerView.kt +220 -0
  6. package/android/src/main/java/org/maplibre/reactnative/components/annotations/markerview/MLRNMarkerViewContent.kt +50 -0
  7. package/android/src/main/java/org/maplibre/reactnative/components/annotations/markerview/MLRNMarkerViewManager.kt +81 -0
  8. package/android/src/main/java/org/maplibre/reactnative/components/annotations/markerview/MarkerViewManager.kt +127 -0
  9. package/android/src/main/java/org/maplibre/reactnative/components/annotations/pointannotation/MLRNPointAnnotation.kt +407 -0
  10. package/android/src/main/java/org/maplibre/reactnative/components/annotations/pointannotation/MLRNPointAnnotationManager.kt +105 -0
  11. package/android/src/main/java/org/maplibre/reactnative/components/mapview/MLRNMapView.kt +38 -37
  12. package/android/src/main/java/org/maplibre/reactnative/events/PointAnnotationClickEvent.java +1 -1
  13. package/android/src/main/java/org/maplibre/reactnative/events/PointAnnotationDragEvent.java +1 -1
  14. package/android/src/main/java/org/maplibre/reactnative/events/PointAnnotationEvent.kt +30 -0
  15. package/ios/components/annotations/callout/MLRNCalloutComponentView.h +10 -0
  16. package/ios/components/annotations/callout/MLRNCalloutComponentView.mm +91 -0
  17. package/ios/components/annotations/point-annotation/MLRNPointAnnotation.h +44 -0
  18. package/ios/components/annotations/{MLRNPointAnnotation.m → point-annotation/MLRNPointAnnotation.m} +69 -35
  19. package/ios/components/annotations/point-annotation/MLRNPointAnnotationComponentView.h +10 -0
  20. package/ios/components/annotations/point-annotation/MLRNPointAnnotationComponentView.mm +331 -0
  21. package/ios/components/map-view/MLRNMapView.m +4 -5
  22. package/lib/commonjs/components/annotations/callout/Callout.js +94 -0
  23. package/lib/commonjs/components/annotations/callout/Callout.js.map +1 -0
  24. package/lib/commonjs/components/annotations/callout/CalloutNativeComponent.ts +11 -0
  25. package/lib/commonjs/components/annotations/marker-view/MarkerView.js +70 -0
  26. package/lib/commonjs/components/annotations/marker-view/MarkerView.js.map +1 -0
  27. package/lib/commonjs/components/annotations/marker-view/MarkerViewNativeComponent.ts +30 -0
  28. package/lib/commonjs/components/annotations/point-annotation/PointAnnotation.js +88 -0
  29. package/lib/commonjs/components/annotations/point-annotation/PointAnnotation.js.map +1 -0
  30. package/lib/commonjs/components/annotations/point-annotation/PointAnnotationNativeComponent.ts +58 -0
  31. package/lib/commonjs/index.js +3 -3
  32. package/lib/commonjs/index.js.map +1 -1
  33. package/lib/commonjs/types/Anchor.js +68 -0
  34. package/lib/commonjs/types/Anchor.js.map +1 -0
  35. package/lib/commonjs/utils/animated/Animated.js +4 -0
  36. package/lib/commonjs/utils/animated/Animated.js.map +1 -1
  37. package/lib/module/components/annotations/callout/Callout.js +88 -0
  38. package/lib/module/components/annotations/callout/Callout.js.map +1 -0
  39. package/lib/module/components/annotations/callout/CalloutNativeComponent.ts +11 -0
  40. package/lib/module/components/annotations/marker-view/MarkerView.js +64 -0
  41. package/lib/module/components/annotations/marker-view/MarkerView.js.map +1 -0
  42. package/lib/module/components/annotations/marker-view/MarkerViewNativeComponent.ts +30 -0
  43. package/lib/module/components/annotations/point-annotation/PointAnnotation.js +83 -0
  44. package/lib/module/components/annotations/point-annotation/PointAnnotation.js.map +1 -0
  45. package/lib/module/components/annotations/point-annotation/PointAnnotationNativeComponent.ts +58 -0
  46. package/lib/module/index.js +3 -3
  47. package/lib/module/index.js.map +1 -1
  48. package/lib/module/types/Anchor.js +64 -0
  49. package/lib/module/types/Anchor.js.map +1 -0
  50. package/lib/module/utils/animated/Animated.js +4 -0
  51. package/lib/module/utils/animated/Animated.js.map +1 -1
  52. package/lib/typescript/{module/src/components/annotations → commonjs/src/components/annotations/callout}/Callout.d.ts +9 -9
  53. package/lib/typescript/commonjs/src/components/annotations/callout/Callout.d.ts.map +1 -0
  54. package/lib/typescript/commonjs/src/components/annotations/callout/CalloutNativeComponent.d.ts +6 -0
  55. package/lib/typescript/commonjs/src/components/annotations/callout/CalloutNativeComponent.d.ts.map +1 -0
  56. package/lib/typescript/commonjs/src/components/annotations/marker-view/MarkerView.d.ts +52 -0
  57. package/lib/typescript/commonjs/src/components/annotations/marker-view/MarkerView.d.ts.map +1 -0
  58. package/lib/typescript/commonjs/src/components/annotations/marker-view/MarkerViewNativeComponent.d.ts +21 -0
  59. package/lib/typescript/commonjs/src/components/annotations/marker-view/MarkerViewNativeComponent.d.ts.map +1 -0
  60. package/lib/typescript/commonjs/src/components/annotations/point-annotation/PointAnnotation.d.ts +95 -0
  61. package/lib/typescript/commonjs/src/components/annotations/point-annotation/PointAnnotation.d.ts.map +1 -0
  62. package/lib/typescript/commonjs/src/components/annotations/point-annotation/PointAnnotationNativeComponent.d.ts +43 -0
  63. package/lib/typescript/commonjs/src/components/annotations/point-annotation/PointAnnotationNativeComponent.d.ts.map +1 -0
  64. package/lib/typescript/commonjs/src/index.d.ts +4 -4
  65. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  66. package/lib/typescript/commonjs/src/types/Anchor.d.ts +17 -0
  67. package/lib/typescript/commonjs/src/types/Anchor.d.ts.map +1 -0
  68. package/lib/typescript/commonjs/src/utils/animated/Animated.d.ts +1 -0
  69. package/lib/typescript/commonjs/src/utils/animated/Animated.d.ts.map +1 -1
  70. package/lib/typescript/{commonjs/src/components/annotations → module/src/components/annotations/callout}/Callout.d.ts +9 -9
  71. package/lib/typescript/module/src/components/annotations/callout/Callout.d.ts.map +1 -0
  72. package/lib/typescript/module/src/components/annotations/callout/CalloutNativeComponent.d.ts +6 -0
  73. package/lib/typescript/module/src/components/annotations/callout/CalloutNativeComponent.d.ts.map +1 -0
  74. package/lib/typescript/module/src/components/annotations/marker-view/MarkerView.d.ts +52 -0
  75. package/lib/typescript/module/src/components/annotations/marker-view/MarkerView.d.ts.map +1 -0
  76. package/lib/typescript/module/src/components/annotations/marker-view/MarkerViewNativeComponent.d.ts +21 -0
  77. package/lib/typescript/module/src/components/annotations/marker-view/MarkerViewNativeComponent.d.ts.map +1 -0
  78. package/lib/typescript/module/src/components/annotations/point-annotation/PointAnnotation.d.ts +95 -0
  79. package/lib/typescript/module/src/components/annotations/point-annotation/PointAnnotation.d.ts.map +1 -0
  80. package/lib/typescript/module/src/components/annotations/point-annotation/PointAnnotationNativeComponent.d.ts +43 -0
  81. package/lib/typescript/module/src/components/annotations/point-annotation/PointAnnotationNativeComponent.d.ts.map +1 -0
  82. package/lib/typescript/module/src/index.d.ts +4 -4
  83. package/lib/typescript/module/src/index.d.ts.map +1 -1
  84. package/lib/typescript/module/src/types/Anchor.d.ts +17 -0
  85. package/lib/typescript/module/src/types/Anchor.d.ts.map +1 -0
  86. package/lib/typescript/module/src/utils/animated/Animated.d.ts +1 -0
  87. package/lib/typescript/module/src/utils/animated/Animated.d.ts.map +1 -1
  88. package/package.json +3 -1
  89. package/src/components/annotations/callout/Callout.tsx +145 -0
  90. package/src/components/annotations/callout/CalloutNativeComponent.ts +11 -0
  91. package/src/components/annotations/marker-view/MarkerView.tsx +124 -0
  92. package/src/components/annotations/marker-view/MarkerViewNativeComponent.ts +30 -0
  93. package/src/components/annotations/point-annotation/PointAnnotation.tsx +219 -0
  94. package/src/components/annotations/point-annotation/PointAnnotationNativeComponent.ts +58 -0
  95. package/src/index.ts +15 -4
  96. package/src/types/Anchor.ts +44 -0
  97. package/src/utils/animated/Animated.tsx +6 -0
  98. package/android/src/main/java/org/maplibre/reactnative/components/annotations/MLRNCallout.java +0 -11
  99. package/android/src/main/java/org/maplibre/reactnative/components/annotations/MLRNCalloutManager.java +0 -18
  100. package/android/src/main/java/org/maplibre/reactnative/components/annotations/MLRNMarkerView.java +0 -112
  101. package/android/src/main/java/org/maplibre/reactnative/components/annotations/MLRNMarkerViewManager.java +0 -45
  102. package/android/src/main/java/org/maplibre/reactnative/components/annotations/MLRNPointAnnotation.java +0 -361
  103. package/android/src/main/java/org/maplibre/reactnative/components/annotations/MLRNPointAnnotationManager.java +0 -84
  104. package/android/src/main/java/org/maplibre/reactnative/components/annotations/MarkerView.java +0 -23
  105. package/android/src/main/java/org/maplibre/reactnative/components/annotations/MarkerViewManager.java +0 -69
  106. package/ios/components/annotations/MLRNCalloutManager.h +0 -5
  107. package/ios/components/annotations/MLRNCalloutManager.m +0 -12
  108. package/ios/components/annotations/MLRNPointAnnotation.h +0 -33
  109. package/ios/components/annotations/MLRNPointAnnotationManager.h +0 -5
  110. package/ios/components/annotations/MLRNPointAnnotationManager.m +0 -27
  111. package/lib/commonjs/components/annotations/Callout.js +0 -101
  112. package/lib/commonjs/components/annotations/Callout.js.map +0 -1
  113. package/lib/commonjs/components/annotations/MarkerView.js +0 -60
  114. package/lib/commonjs/components/annotations/MarkerView.js.map +0 -1
  115. package/lib/commonjs/components/annotations/PointAnnotation.js +0 -114
  116. package/lib/commonjs/components/annotations/PointAnnotation.js.map +0 -1
  117. package/lib/module/components/annotations/Callout.js +0 -96
  118. package/lib/module/components/annotations/Callout.js.map +0 -1
  119. package/lib/module/components/annotations/MarkerView.js +0 -55
  120. package/lib/module/components/annotations/MarkerView.js.map +0 -1
  121. package/lib/module/components/annotations/PointAnnotation.js +0 -110
  122. package/lib/module/components/annotations/PointAnnotation.js.map +0 -1
  123. package/lib/typescript/commonjs/src/components/annotations/Callout.d.ts.map +0 -1
  124. package/lib/typescript/commonjs/src/components/annotations/MarkerView.d.ts +0 -44
  125. package/lib/typescript/commonjs/src/components/annotations/MarkerView.d.ts.map +0 -1
  126. package/lib/typescript/commonjs/src/components/annotations/PointAnnotation.d.ts +0 -90
  127. package/lib/typescript/commonjs/src/components/annotations/PointAnnotation.d.ts.map +0 -1
  128. package/lib/typescript/module/src/components/annotations/Callout.d.ts.map +0 -1
  129. package/lib/typescript/module/src/components/annotations/MarkerView.d.ts +0 -44
  130. package/lib/typescript/module/src/components/annotations/MarkerView.d.ts.map +0 -1
  131. package/lib/typescript/module/src/components/annotations/PointAnnotation.d.ts +0 -90
  132. package/lib/typescript/module/src/components/annotations/PointAnnotation.d.ts.map +0 -1
  133. package/src/components/annotations/Callout.tsx +0 -139
  134. package/src/components/annotations/MarkerView.tsx +0 -86
  135. package/src/components/annotations/PointAnnotation.tsx +0 -240
  136. /package/ios/components/annotations/{MLRNCallout.h → callout/MLRNCallout.h} +0 -0
  137. /package/ios/components/annotations/{MLRNCallout.m → callout/MLRNCallout.m} +0 -0
@@ -0,0 +1,331 @@
1
+ #import "MLRNPointAnnotationComponentView.h"
2
+
3
+ #import <react/renderer/components/MapLibreReactNativeSpec/ComponentDescriptors.h>
4
+ #import <react/renderer/components/MapLibreReactNativeSpec/EventEmitters.h>
5
+ #import <react/renderer/components/MapLibreReactNativeSpec/Props.h>
6
+ #import <react/renderer/components/MapLibreReactNativeSpec/RCTComponentViewHelpers.h>
7
+
8
+ #import "RCTFabricComponentsPlugins.h"
9
+
10
+ #import <React/RCTConversions.h>
11
+ #import <React/UIView+React.h>
12
+ #import "MLRNPointAnnotation.h"
13
+ #import "MLRNCallout.h"
14
+
15
+ using namespace facebook::react;
16
+
17
+ // MARK: - MLRNPointAnnotationComponentView
18
+
19
+ @interface MLRNPointAnnotationComponentView () <RCTMLRNPointAnnotationViewProtocol>
20
+
21
+ @end
22
+
23
+ @implementation MLRNPointAnnotationComponentView {
24
+ MLRNPointAnnotation *_view;
25
+ }
26
+
27
+ + (BOOL)shouldBeRecycled {
28
+ // Prevent Fabric from recycling this view - MapLibre reparents annotation views
29
+ // which conflicts with Fabric's view hierarchy management
30
+ return NO;
31
+ }
32
+
33
+ - (UIView *)contentView {
34
+ // Return _view so MapView's mountChildComponentView can find it via contentView
35
+ // We don't set self.contentView = _view directly to avoid Fabric's view management
36
+ return _view;
37
+ }
38
+
39
+ - (instancetype)initWithFrame:(CGRect)frame {
40
+ if (self = [super initWithFrame:frame]) {
41
+ static const auto defaultProps = std::make_shared<const MLRNPointAnnotationProps>();
42
+ _props = defaultProps;
43
+ [self prepareView];
44
+ }
45
+
46
+ return self;
47
+ }
48
+
49
+ - (void)prepareView {
50
+ _view = [[MLRNPointAnnotation alloc] init];
51
+
52
+ // Capture weak self reference to prevent retain cycle
53
+ __weak __typeof__(self) weakSelf = self;
54
+
55
+ [_view setReactOnSelected:^(NSDictionary *event) {
56
+ __typeof__(self) strongSelf = weakSelf;
57
+
58
+ if (strongSelf != nullptr && strongSelf->_eventEmitter != nullptr) {
59
+ NSString *idValue = event[@"id"];
60
+ facebook::react::MLRNPointAnnotationEventEmitter::OnSelected eventStruct{
61
+ std::string([idValue UTF8String] ?: ""),
62
+ folly::dynamic::array([event[@"lngLat"][0] doubleValue],
63
+ [event[@"lngLat"][1] doubleValue]),
64
+ folly::dynamic::array([event[@"point"][0] doubleValue],
65
+ [event[@"point"][1] doubleValue])};
66
+
67
+ std::dynamic_pointer_cast<const facebook::react::MLRNPointAnnotationEventEmitter>(
68
+ strongSelf->_eventEmitter)
69
+ ->onSelected(eventStruct);
70
+ }
71
+ }];
72
+
73
+ [_view setReactOnDeselected:^(NSDictionary *event) {
74
+ __typeof__(self) strongSelf = weakSelf;
75
+
76
+ if (strongSelf != nullptr && strongSelf->_eventEmitter != nullptr) {
77
+ NSString *idValue = event[@"id"];
78
+ facebook::react::MLRNPointAnnotationEventEmitter::OnDeselected eventStruct{
79
+ std::string([idValue UTF8String] ?: ""),
80
+ folly::dynamic::array([event[@"lngLat"][0] doubleValue],
81
+ [event[@"lngLat"][1] doubleValue]),
82
+ folly::dynamic::array([event[@"point"][0] doubleValue],
83
+ [event[@"point"][1] doubleValue])};
84
+
85
+ std::dynamic_pointer_cast<const facebook::react::MLRNPointAnnotationEventEmitter>(
86
+ strongSelf->_eventEmitter)
87
+ ->onDeselected(eventStruct);
88
+ }
89
+ }];
90
+
91
+ [_view setReactOnDragStart:^(NSDictionary *event) {
92
+ __typeof__(self) strongSelf = weakSelf;
93
+
94
+ if (strongSelf != nullptr && strongSelf->_eventEmitter != nullptr) {
95
+ NSString *idValue = event[@"id"];
96
+ facebook::react::MLRNPointAnnotationEventEmitter::OnDragStart eventStruct{
97
+ std::string([idValue UTF8String] ?: ""),
98
+ folly::dynamic::array([event[@"lngLat"][0] doubleValue],
99
+ [event[@"lngLat"][1] doubleValue]),
100
+ folly::dynamic::array([event[@"point"][0] doubleValue],
101
+ [event[@"point"][1] doubleValue])};
102
+
103
+ std::dynamic_pointer_cast<const facebook::react::MLRNPointAnnotationEventEmitter>(
104
+ strongSelf->_eventEmitter)
105
+ ->onDragStart(eventStruct);
106
+ }
107
+ }];
108
+
109
+ [_view setReactOnDrag:^(NSDictionary *event) {
110
+ __typeof__(self) strongSelf = weakSelf;
111
+
112
+ if (strongSelf != nullptr && strongSelf->_eventEmitter != nullptr) {
113
+ NSString *idValue = event[@"id"];
114
+ facebook::react::MLRNPointAnnotationEventEmitter::OnDrag eventStruct{
115
+ std::string([idValue UTF8String] ?: ""),
116
+ folly::dynamic::array([event[@"lngLat"][0] doubleValue],
117
+ [event[@"lngLat"][1] doubleValue]),
118
+ folly::dynamic::array([event[@"point"][0] doubleValue],
119
+ [event[@"point"][1] doubleValue])};
120
+
121
+ std::dynamic_pointer_cast<const facebook::react::MLRNPointAnnotationEventEmitter>(
122
+ strongSelf->_eventEmitter)
123
+ ->onDrag(eventStruct);
124
+ }
125
+ }];
126
+
127
+ [_view setReactOnDragEnd:^(NSDictionary *event) {
128
+ __typeof__(self) strongSelf = weakSelf;
129
+
130
+ if (strongSelf != nullptr && strongSelf->_eventEmitter != nullptr) {
131
+ NSString *idValue = event[@"id"];
132
+ facebook::react::MLRNPointAnnotationEventEmitter::OnDragEnd eventStruct{
133
+ std::string([idValue UTF8String] ?: ""),
134
+ folly::dynamic::array([event[@"lngLat"][0] doubleValue],
135
+ [event[@"lngLat"][1] doubleValue]),
136
+ folly::dynamic::array([event[@"point"][0] doubleValue],
137
+ [event[@"point"][1] doubleValue])};
138
+
139
+ std::dynamic_pointer_cast<const facebook::react::MLRNPointAnnotationEventEmitter>(
140
+ strongSelf->_eventEmitter)
141
+ ->onDragEnd(eventStruct);
142
+ }
143
+ }];
144
+
145
+ // Add _view as a subview (not contentView) so the MapView can discover it
146
+ // via its addToMap: method which iterates through subviews looking for
147
+ // MLRNPointAnnotation instances to set their map property.
148
+ // Note: MapLibre will reparent _view when displaying the annotation,
149
+ // but that's fine - the initial subview relationship lets MapView find it.
150
+ [self addSubview:_view];
151
+ }
152
+
153
+ - (void)updateLayoutMetrics:(const facebook::react::LayoutMetrics &)layoutMetrics
154
+ oldLayoutMetrics:(const facebook::react::LayoutMetrics &)oldLayoutMetrics {
155
+ [super updateLayoutMetrics:layoutMetrics oldLayoutMetrics:oldLayoutMetrics];
156
+
157
+ // Forward layout to _view - this triggers reactSetFrame: which adds the annotation to the map
158
+ CGRect frame = CGRectMake(
159
+ layoutMetrics.frame.origin.x,
160
+ layoutMetrics.frame.origin.y,
161
+ layoutMetrics.frame.size.width,
162
+ layoutMetrics.frame.size.height
163
+ );
164
+ [_view reactSetFrame:frame];
165
+ }
166
+
167
+ - (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView
168
+ index:(NSInteger)index {
169
+ // Track custom children for Fabric - needed for getAnnotationView to know
170
+ // if this is a custom annotation or should use the default pin
171
+ BOOL needsAnnotationRefresh = NO;
172
+
173
+ BOOL isCallout = NO;
174
+
175
+ if ([childComponentView isKindOfClass:[RCTViewComponentView class]]) {
176
+ UIView *contentView = ((RCTViewComponentView *)childComponentView).contentView;
177
+ if ([contentView isKindOfClass:[MLRNCallout class]]) {
178
+ // Set up calloutView reference for Callout children
179
+ // NOTE: We do NOT add Callout as a subview - MapLibre will present it
180
+ // when the annotation is selected via calloutViewForAnnotation delegate
181
+ _view.calloutView = (MLRNCallout *)contentView;
182
+ _view.calloutView.representedObject = _view;
183
+ isCallout = YES;
184
+ } else {
185
+ // Track non-Callout custom children (custom annotation views)
186
+ // If this is the first custom child and annotation is already on map,
187
+ // we need to refresh so MapLibre picks up the custom view
188
+ if (_view.customChildCount == 0 && _view.map != nil) {
189
+ needsAnnotationRefresh = YES;
190
+ }
191
+ _view.customChildCount++;
192
+ }
193
+ }
194
+
195
+ // Add non-Callout children directly to _view (the annotation view).
196
+ // We do NOT call super because we want children in _view, not in self.
197
+ // This allows children to move with _view when MapLibre reparents it.
198
+ // Callouts are NOT added as subviews - they're presented by MapLibre on selection.
199
+ // Note: We use the current subview count as the index because Callouts are skipped,
200
+ // so React's index won't match our actual subview indices.
201
+ if (!isCallout) {
202
+ [_view addSubview:childComponentView];
203
+ }
204
+
205
+ // If annotation was added before children were mounted, MapLibre would have
206
+ // returned nil from getAnnotationView (no custom children). Now that we have
207
+ // children, remove and re-add to trigger viewForAnnotation: again.
208
+ if (needsAnnotationRefresh && [_view.map.annotations containsObject:_view]) {
209
+ [_view.map removeAnnotation:_view];
210
+ [_view.map addAnnotation:_view];
211
+ }
212
+ }
213
+
214
+ - (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView
215
+ index:(NSInteger)index {
216
+ // Update tracking for custom children
217
+ BOOL isCallout = NO;
218
+
219
+ if ([childComponentView isKindOfClass:[RCTViewComponentView class]]) {
220
+ UIView *contentView = ((RCTViewComponentView *)childComponentView).contentView;
221
+ if ([contentView isKindOfClass:[MLRNCallout class]]) {
222
+ // Clear calloutView reference - Callout was never added as subview
223
+ _view.calloutView = nil;
224
+ isCallout = YES;
225
+ } else if (_view.customChildCount > 0) {
226
+ // Decrement custom child count
227
+ _view.customChildCount--;
228
+ }
229
+ }
230
+
231
+ // Remove from _view (not from self, since we added to _view)
232
+ // Don't remove Callout since it was never added as subview
233
+ if (!isCallout) {
234
+ [childComponentView removeFromSuperview];
235
+ }
236
+ }
237
+
238
+ #pragma mark - RCTComponentViewProtocol
239
+
240
+ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps {
241
+ const auto &oldViewProps = *std::static_pointer_cast<MLRNPointAnnotationProps const>(_props);
242
+ const auto &newViewProps = *std::static_pointer_cast<MLRNPointAnnotationProps const>(props);
243
+
244
+ if (oldViewProps.id != newViewProps.id) {
245
+ NSString *idValue = [NSString stringWithCString:newViewProps.id.c_str()
246
+ encoding:NSUTF8StringEncoding];
247
+ [_view setId:idValue];
248
+ }
249
+
250
+ if (oldViewProps.title != newViewProps.title) {
251
+ NSString *titleValue = newViewProps.title.empty()
252
+ ? nil
253
+ : [NSString stringWithCString:newViewProps.title.c_str()
254
+ encoding:NSUTF8StringEncoding];
255
+ [_view setReactTitle:titleValue];
256
+ }
257
+
258
+ if (oldViewProps.snippet != newViewProps.snippet) {
259
+ NSString *snippetValue = newViewProps.snippet.empty()
260
+ ? nil
261
+ : [NSString stringWithCString:newViewProps.snippet.c_str()
262
+ encoding:NSUTF8StringEncoding];
263
+ [_view setReactSnippet:snippetValue];
264
+ }
265
+
266
+ if (oldViewProps.selected != newViewProps.selected) {
267
+ [_view setReactSelected:newViewProps.selected];
268
+ }
269
+
270
+ if (oldViewProps.draggable != newViewProps.draggable) {
271
+ [_view setReactDraggable:newViewProps.draggable];
272
+ }
273
+
274
+ if (!oldViewProps.lngLat.isNull() || !newViewProps.lngLat.isNull()) {
275
+ if (newViewProps.lngLat.isArray() && newViewProps.lngLat.size() >= 2) {
276
+ NSArray<NSNumber *> *lngLat = @[
277
+ @(newViewProps.lngLat[0].asDouble()),
278
+ @(newViewProps.lngLat[1].asDouble())
279
+ ];
280
+ [_view setReactLngLat:lngLat];
281
+ }
282
+ }
283
+
284
+ if (oldViewProps.anchor.x != newViewProps.anchor.x ||
285
+ oldViewProps.anchor.y != newViewProps.anchor.y) {
286
+ NSDictionary *anchor = @{
287
+ @"x" : @(newViewProps.anchor.x),
288
+ @"y" : @(newViewProps.anchor.y)
289
+ };
290
+ [_view setAnchor:anchor];
291
+ }
292
+
293
+ if (oldViewProps.offset.x != newViewProps.offset.x ||
294
+ oldViewProps.offset.y != newViewProps.offset.y) {
295
+ NSDictionary *offset = @{
296
+ @"x" : @(newViewProps.offset.x),
297
+ @"y" : @(newViewProps.offset.y)
298
+ };
299
+ [_view setOffset:offset];
300
+ }
301
+
302
+ // Handle zIndex from style prop - it's in the base ViewProps
303
+ if (oldViewProps.zIndex != newViewProps.zIndex) {
304
+ if (newViewProps.zIndex.has_value()) {
305
+ [_view setZIndex:(CGFloat)newViewProps.zIndex.value()];
306
+ }
307
+ }
308
+
309
+ [super updateProps:props oldProps:oldProps];
310
+ }
311
+
312
+ + (ComponentDescriptorProvider)componentDescriptorProvider {
313
+ return concreteComponentDescriptorProvider<MLRNPointAnnotationComponentDescriptor>();
314
+ }
315
+
316
+ #pragma mark - Native Commands
317
+
318
+ - (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args {
319
+ RCTMLRNPointAnnotationHandleCommand(self, commandName, args);
320
+ }
321
+
322
+ - (void)refresh {
323
+ // refresh is only used on Android to rerender the bitmap
324
+ // On iOS, this is a no-op
325
+ }
326
+
327
+ @end
328
+
329
+ Class<RCTComponentViewProtocol> MLRNPointAnnotationCls(void) {
330
+ return MLRNPointAnnotationComponentView.class;
331
+ }
@@ -613,9 +613,8 @@ static double const M2PI = M_PI * 2;
613
613
  if ([annotation isKindOfClass:[MLRNPointAnnotation class]]) {
614
614
  MLRNPointAnnotation *rctAnnotation = (MLRNPointAnnotation *)annotation;
615
615
 
616
- if (rctAnnotation.onSelected != nil) {
617
- MLRNMapTouchEvent *event = [MLRNMapTouchEvent makeAnnotationTapEvent:rctAnnotation];
618
- rctAnnotation.onSelected([event toJSON]);
616
+ if (rctAnnotation.reactOnSelected != nil) {
617
+ rctAnnotation.reactOnSelected([rctAnnotation makeEventPayload]);
619
618
  }
620
619
  }
621
620
  }
@@ -624,8 +623,8 @@ static double const M2PI = M_PI * 2;
624
623
  if ([annotation isKindOfClass:[MLRNPointAnnotation class]]) {
625
624
  MLRNPointAnnotation *rctAnnotation = (MLRNPointAnnotation *)annotation;
626
625
 
627
- if (rctAnnotation.onDeselected != nil) {
628
- rctAnnotation.onDeselected(nil);
626
+ if (rctAnnotation.reactOnDeselected != nil) {
627
+ rctAnnotation.reactOnDeselected([rctAnnotation makeEventPayload]);
629
628
  }
630
629
  }
631
630
  }
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Callout = void 0;
7
+ var _react = require("react");
8
+ var _reactNative = require("react-native");
9
+ var _CalloutNativeComponent = _interopRequireDefault(require("./CalloutNativeComponent"));
10
+ var _jsxRuntime = require("react/jsx-runtime");
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ const styles = _reactNative.StyleSheet.create({
13
+ animated: {
14
+ alignItems: "center",
15
+ justifyContent: "center",
16
+ width: 180,
17
+ zIndex: 9999999
18
+ },
19
+ content: {
20
+ backgroundColor: "white",
21
+ borderColor: "rgba(0, 0, 0, 0.2)",
22
+ borderRadius: 3,
23
+ borderWidth: 1,
24
+ flex: 1,
25
+ padding: 8,
26
+ position: "relative"
27
+ },
28
+ tip: {
29
+ backgroundColor: "transparent",
30
+ borderBottomColor: "transparent",
31
+ borderBottomWidth: 0,
32
+ borderLeftColor: "transparent",
33
+ borderLeftWidth: 8,
34
+ borderRightColor: "transparent",
35
+ borderRightWidth: 8,
36
+ borderTopColor: "white",
37
+ borderTopWidth: 16,
38
+ elevation: 0,
39
+ marginTop: -2,
40
+ zIndex: 1000
41
+ },
42
+ title: {
43
+ color: "black",
44
+ textAlign: "center"
45
+ }
46
+ });
47
+ /**
48
+ * Callout that displays information about a selected annotation near the annotation.
49
+ */
50
+ const Callout = ({
51
+ title,
52
+ style,
53
+ animatedStyle,
54
+ contentStyle,
55
+ tipStyle,
56
+ titleStyle,
57
+ children,
58
+ testID,
59
+ ...props
60
+ }) => {
61
+ const calloutContent = _react.Children.count(children) > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Animated.View, {
62
+ testID: testID ? `${testID}-animated` : undefined,
63
+ style: animatedStyle,
64
+ ...props,
65
+ children: children
66
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Animated.View, {
67
+ testID: testID ? `${testID}-animated` : undefined,
68
+ style: [styles.animated, animatedStyle],
69
+ ...props,
70
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
71
+ testID: testID ? `${testID}-content` : undefined,
72
+ style: [styles.content, contentStyle],
73
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
74
+ testID: testID ? `${testID}-title` : undefined,
75
+ style: [styles.title, titleStyle],
76
+ children: title
77
+ })
78
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
79
+ testID: testID ? `${testID}-tip` : undefined,
80
+ style: [styles.tip, tipStyle]
81
+ })]
82
+ });
83
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_CalloutNativeComponent.default, {
84
+ testID: testID,
85
+ style: [{
86
+ position: "absolute",
87
+ zIndex: 999,
88
+ backgroundColor: "transparent"
89
+ }, style],
90
+ children: calloutContent
91
+ });
92
+ };
93
+ exports.Callout = Callout;
94
+ //# sourceMappingURL=Callout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","require","_reactNative","_CalloutNativeComponent","_interopRequireDefault","_jsxRuntime","e","__esModule","default","styles","StyleSheet","create","animated","alignItems","justifyContent","width","zIndex","content","backgroundColor","borderColor","borderRadius","borderWidth","flex","padding","position","tip","borderBottomColor","borderBottomWidth","borderLeftColor","borderLeftWidth","borderRightColor","borderRightWidth","borderTopColor","borderTopWidth","elevation","marginTop","title","color","textAlign","Callout","style","animatedStyle","contentStyle","tipStyle","titleStyle","children","testID","props","calloutContent","Children","count","jsx","Animated","View","undefined","jsxs","Text","exports"],"sourceRoot":"../../../../../src","sources":["components/annotations/callout/Callout.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AASA,IAAAE,uBAAA,GAAAC,sBAAA,CAAAH,OAAA;AAA8D,IAAAI,WAAA,GAAAJ,OAAA;AAAA,SAAAG,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE9D,MAAMG,MAAM,GAAGC,uBAAU,CAACC,MAAM,CAAC;EAC/BC,QAAQ,EAAE;IACRC,UAAU,EAAE,QAAQ;IACpBC,cAAc,EAAE,QAAQ;IACxBC,KAAK,EAAE,GAAG;IACVC,MAAM,EAAE;EACV,CAAC;EACDC,OAAO,EAAE;IACPC,eAAe,EAAE,OAAO;IACxBC,WAAW,EAAE,oBAAoB;IACjCC,YAAY,EAAE,CAAC;IACfC,WAAW,EAAE,CAAC;IACdC,IAAI,EAAE,CAAC;IACPC,OAAO,EAAE,CAAC;IACVC,QAAQ,EAAE;EACZ,CAAC;EACDC,GAAG,EAAE;IACHP,eAAe,EAAE,aAAa;IAC9BQ,iBAAiB,EAAE,aAAa;IAChCC,iBAAiB,EAAE,CAAC;IACpBC,eAAe,EAAE,aAAa;IAC9BC,eAAe,EAAE,CAAC;IAClBC,gBAAgB,EAAE,aAAa;IAC/BC,gBAAgB,EAAE,CAAC;IACnBC,cAAc,EAAE,OAAO;IACvBC,cAAc,EAAE,EAAE;IAClBC,SAAS,EAAE,CAAC;IACZC,SAAS,EAAE,CAAC,CAAC;IACbnB,MAAM,EAAE;EACV,CAAC;EACDoB,KAAK,EAAE;IACLC,KAAK,EAAE,OAAO;IACdC,SAAS,EAAE;EACb;AACF,CAAC,CAAC;AAoCF;AACA;AACA;AACO,MAAMC,OAAO,GAAGA,CAAC;EACtBH,KAAK;EACLI,KAAK;EACLC,aAAa;EACbC,YAAY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,CAAC/B,MAAM,CAACgB,GAAG,EAAEkB,QAAQ;IAAE,CAC/B,CAAC;EAAA,CACW,CAChB;EAEH,oBACE,IAAAtC,WAAA,CAAA8C,GAAA,EAAChD,uBAAA,CAAAK,OAAsB;IACrBsC,MAAM,EAAEA,MAAO;IACfN,KAAK,EAAE,CACL;MACEhB,QAAQ,EAAE,UAAU;MACpBR,MAAM,EAAE,GAAG;MACXE,eAAe,EAAE;IACnB,CAAC,EACDsB,KAAK,CACL;IAAAK,QAAA,EAEDG;EAAc,CACO,CAAC;AAE7B,CAAC;AAACS,OAAA,CAAAlB,OAAA,GAAAA,OAAA","ignoreList":[]}
@@ -0,0 +1,11 @@
1
+ import {
2
+ codegenNativeComponent,
3
+ type HostComponent,
4
+ type ViewProps,
5
+ } from "react-native";
6
+
7
+ export interface NativeProps extends ViewProps {}
8
+
9
+ export default codegenNativeComponent<NativeProps>(
10
+ "MLRNCallout",
11
+ ) as HostComponent<NativeProps>;
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.MarkerView = void 0;
7
+ var _react = require("react");
8
+ var _reactNative = require("react-native");
9
+ var _MarkerViewNativeComponent = _interopRequireDefault(require("./MarkerViewNativeComponent"));
10
+ var _useFrozenId = require("../../../hooks/useFrozenId.js");
11
+ var _Anchor = require("../../../types/Anchor.js");
12
+ var _PointAnnotation = require("../point-annotation/PointAnnotation.js");
13
+ var _jsxRuntime = require("react/jsx-runtime");
14
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
+ /**
16
+ * MarkerView allows you to place an interactive React Native View on the map.
17
+ *
18
+ * If you have static view consider using PointAnnotation or SymbolLayer for better performance.
19
+ *
20
+ * Implemented through:
21
+ * - Android: Native MarkerViewManager using map projection
22
+ * - iOS: [MLNPointAnnotation](https://maplibre.org/maplibre-native/ios/latest/documentation/maplibre/mlnpointannotation/)
23
+ */
24
+ const MarkerView = ({
25
+ id,
26
+ anchor = "center",
27
+ offset,
28
+ ...props
29
+ }) => {
30
+ const nativeRef = (0, _react.useRef)(null);
31
+ const nativeAnchor = (0, _Anchor.anchorToNative)(anchor);
32
+ const nativeOffset = offset ? {
33
+ x: offset[0],
34
+ y: offset[1]
35
+ } : undefined;
36
+ const pointAnnotationRef = (0, _react.useRef)(null);
37
+ const frozenId = (0, _useFrozenId.useFrozenId)(id);
38
+ if (_reactNative.Platform.OS === "ios") {
39
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_PointAnnotation.PointAnnotation, {
40
+ ref: pointAnnotationRef,
41
+ id: frozenId,
42
+ anchor: anchor,
43
+ offset: offset,
44
+ ...props
45
+ });
46
+ }
47
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_MarkerViewNativeComponent.default, {
48
+ ref: nativeRef,
49
+ id: frozenId,
50
+ anchor: nativeAnchor,
51
+ offset: nativeOffset,
52
+ ...props,
53
+ style: [{
54
+ flex: 0,
55
+ alignSelf: "flex-start",
56
+ overflow: "visible"
57
+ }, props.style],
58
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
59
+ collapsable: false,
60
+ style: {
61
+ flex: 0,
62
+ alignSelf: "flex-start",
63
+ overflow: "visible"
64
+ },
65
+ children: props.children
66
+ })
67
+ });
68
+ };
69
+ exports.MarkerView = MarkerView;
70
+ //# sourceMappingURL=MarkerView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","require","_reactNative","_MarkerViewNativeComponent","_interopRequireDefault","_useFrozenId","_Anchor","_PointAnnotation","_jsxRuntime","e","__esModule","default","MarkerView","id","anchor","offset","props","nativeRef","useRef","nativeAnchor","anchorToNative","nativeOffset","x","y","undefined","pointAnnotationRef","frozenId","useFrozenId","Platform","OS","jsx","PointAnnotation","ref","style","flex","alignSelf","overflow","children","View","collapsable","exports"],"sourceRoot":"../../../../../src","sources":["components/annotations/marker-view/MarkerView.tsx"],"mappings":";;;;;;AAAA,IAAAA,M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AEf,SAAU;IACfJ,EAAE,EAAEa,QAAS;IACbZ,MAAM,EAAEK,YAAa;IACrBJ,MAAM,EAAEM,YAAa;IAAA,GACjBL,KAAK;IACTiB,KAAK,EAAE,CACL;MAAEC,IAAI,EAAE,CAAC;MAAEC,SAAS,EAAE,YAAY;MAAEC,QAAQ,EAAE;IAAU,CAAC,EACzDpB,KAAK,CAACiB,KAAK,CACX;IAAAI,QAAA,eAEF,IAAA7B,WAAA,CAAAsB,GAAA,EAAC5B,YAAA,CAAAoC,IAAI;MACHC,WAAW,EAAE,KAAM;MACnBN,KAAK,EAAE;QAAEC,IAAI,EAAE,CAAC;QAAEC,SAAS,EAAE,YAAY;QAAEC,QAAQ,EAAE;MAAU,CAAE;MAAAC,QAAA,EAEhErB,KAAK,CAACqB;IAAQ,CACX;EAAC,CACkB,CAAC;AAEhC,CAAC;AAACG,OAAA,CAAA5B,UAAA,GAAAA,UAAA","ignoreList":[]}
@@ -0,0 +1,30 @@
1
+ import {
2
+ codegenNativeComponent,
3
+ type CodegenTypes,
4
+ type HostComponent,
5
+ type ViewProps,
6
+ } from "react-native";
7
+
8
+ import type { UnsafeMixed } from "../../../types/codegen/UnsafeMixed";
9
+
10
+ type NativeAnchor = {
11
+ x: CodegenTypes.Double;
12
+ y: CodegenTypes.Double;
13
+ };
14
+
15
+ type NativeOffset = {
16
+ x: CodegenTypes.Double;
17
+ y: CodegenTypes.Double;
18
+ };
19
+
20
+ export interface NativeProps extends ViewProps {
21
+ lngLat: UnsafeMixed<
22
+ [longitude: CodegenTypes.Double, latitude: CodegenTypes.Double]
23
+ >;
24
+ anchor?: NativeAnchor;
25
+ offset?: NativeOffset;
26
+ }
27
+
28
+ export default codegenNativeComponent<NativeProps>(
29
+ "MLRNMarkerView",
30
+ ) as HostComponent<NativeProps>;
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.PointAnnotation = void 0;
7
+ var _react = require("react");
8
+ var _reactNative = require("react-native");
9
+ var _PointAnnotationNativeComponent = _interopRequireWildcard(require("./PointAnnotationNativeComponent"));
10
+ var _useFrozenId = require("../../../hooks/useFrozenId.js");
11
+ var _Anchor = require("../../../types/Anchor.js");
12
+ var _Callout = require("../callout/Callout.js");
13
+ var _jsxRuntime = require("react/jsx-runtime");
14
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
15
+ const styles = _reactNative.StyleSheet.create({
16
+ container: {
17
+ alignItems: "center",
18
+ justifyContent: "center",
19
+ position: "absolute"
20
+ }
21
+ });
22
+ /**
23
+ * PointAnnotation represents a one-dimensional shape located at a single geographical coordinate.
24
+ *
25
+ * Consider using GeoJSONSource and SymbolLayer instead, if you have many points, and you have static images,
26
+ * they'll offer much better performance.
27
+ *
28
+ * If you need interactive views please use MarkerView,
29
+ * as with PointAnnotation on Android child views are rendered onto a bitmap for better performance.
30
+ */
31
+ const PointAnnotation = exports.PointAnnotation = /*#__PURE__*/(0, _react.forwardRef)(({
32
+ id,
33
+ anchor = "center",
34
+ draggable = false,
35
+ offset,
36
+ ...props
37
+ }, ref) => {
38
+ const frozenId = (0, _useFrozenId.useFrozenId)(id);
39
+ const nativeAnchor = (0, _Anchor.anchorToNative)(anchor);
40
+ const nativeOffset = offset ? {
41
+ x: offset[0],
42
+ y: offset[1]
43
+ } : undefined;
44
+ const nativeRef = (0, _react.useRef)(null);
45
+ (0, _react.useImperativeHandle)(ref, () => ({
46
+ refresh
47
+ }));
48
+ function refresh() {
49
+ if (_reactNative.Platform.OS === "android" && nativeRef.current) {
50
+ _PointAnnotationNativeComponent.Commands.refresh(nativeRef.current);
51
+ }
52
+ }
53
+
54
+ // On Android, wrap children in a non-collapsable View to prevent Fabric
55
+ // from flattening the view hierarchy. Without this, Fabric may flatten
56
+ // intermediate Views, causing their backgrounds to disappear.
57
+ // We need to keep Callout separate so native code can identify it.
58
+ const wrappedChildren = (() => {
59
+ if (_reactNative.Platform.OS !== "android") {
60
+ return props.children;
61
+ }
62
+
63
+ // Separate Callout from other children so native can identify it
64
+ const childArray = _react.Children.toArray(props.children);
65
+ const callout = childArray.find(child => /*#__PURE__*/(0, _react.isValidElement)(child) && child.type === _Callout.Callout);
66
+ const otherChildren = childArray.filter(child => ! /*#__PURE__*/(0, _react.isValidElement)(child) || child.type !== _Callout.Callout);
67
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
68
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
69
+ collapsable: false,
70
+ style: {
71
+ overflow: "visible"
72
+ },
73
+ children: otherChildren
74
+ }), callout]
75
+ });
76
+ })();
77
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_PointAnnotationNativeComponent.default, {
78
+ ref: nativeRef,
79
+ ...props,
80
+ id: frozenId,
81
+ anchor: nativeAnchor,
82
+ offset: nativeOffset,
83
+ draggable: draggable,
84
+ style: [props.style, styles.container],
85
+ children: wrappedChildren
86
+ });
87
+ });
88
+ //# sourceMappingURL=PointAnnotation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","require","_reactNative","_PointAnnotationNativeComponent","_interopRequireWildcard","_useFrozenId","_Anchor","_Callout","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","styles","StyleSheet","create","container","alignItems","justifyContent","position","PointAnnotation","exports","forwardRef","id","anchor","draggable","offset","props","ref","frozenId","useFrozenId","nativeAnchor","anchorToNative","nativeOffset","x","y","undefined","nativeRef","useRef","useImperativeHandle","refresh","Platform","OS","current","Commands","wrappedChildren","children","childArray","Children","toArray","callout","find","child","isValidElement","type","Callout","otherChildren","filter","jsxs","Fragment","jsx","View","collapsable","style","overflow"],"sourceRoot":"../../../../../src","sources":["components/annotations/point-annotation/PointAnnotation.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAUA,IAAAC,YAAA,GAAAD,OAAA;AASA,IAAAE,+BAAA,GAAAC,uBAAA,CAAAH,OAAA;AAGA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AAIA,IAAAM,QAAA,GAAAN,OAAA;AAA6C,IAAAO,WAAA,GAAAP,OAAA;AAAA,SAAAG,wBAAAK,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAP,uBAAA,YAAAA,CAAAK,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAA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