react-native-maps 1.21.0-alpha.3 → 1.21.0-alpha.30

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 (70) hide show
  1. package/android/build.gradle +14 -3
  2. package/android/src/main/java/com/rnmaps/fabric/NativeAirMapsModule.java +51 -0
  3. package/android/src/main/java/com/rnmaps/maps/MapAirModulePackage.java +46 -0
  4. package/ios/AirGoogleMaps/AIRGoogleMap.h +8 -2
  5. package/ios/AirGoogleMaps/AIRGoogleMap.m +166 -11
  6. package/ios/AirGoogleMaps/AIRGoogleMapCircle.h +0 -1
  7. package/ios/AirGoogleMaps/AIRGoogleMapCircle.m +20 -11
  8. package/ios/AirGoogleMaps/AIRGoogleMapCoordinate.h +13 -0
  9. package/ios/AirGoogleMaps/AIRGoogleMapCoordinate.m +10 -0
  10. package/ios/AirGoogleMaps/AIRGoogleMapManager.h +7 -0
  11. package/ios/AirGoogleMaps/AIRGoogleMapManager.m +30 -119
  12. package/ios/AirGoogleMaps/AIRGoogleMapMarker.h +2 -0
  13. package/ios/AirGoogleMaps/AIRGoogleMapMarker.m +344 -243
  14. package/ios/AirGoogleMaps/AIRGoogleMapMarkerManager.m +0 -1
  15. package/ios/AirGoogleMaps/AIRGoogleMapOverlay.h +0 -1
  16. package/ios/AirGoogleMaps/AIRGoogleMapPolygon.h +5 -4
  17. package/ios/AirGoogleMaps/AIRGoogleMapPolygon.m +29 -2
  18. package/ios/AirGoogleMaps/AIRGoogleMapPolygonManager.m +3 -3
  19. package/ios/AirGoogleMaps/AIRGoogleMapPolyline.h +3 -2
  20. package/ios/AirGoogleMaps/AIRGoogleMapPolyline.m +2 -3
  21. package/ios/AirGoogleMaps/AIRGoogleMapPolylineManager.m +2 -2
  22. package/ios/AirGoogleMaps/AIRGoogleMapWMSTile.h +1 -1
  23. package/ios/AirGoogleMaps/AIRGoogleMapWMSTile.m +2 -2
  24. package/ios/AirGoogleMaps/RCTConvert+GMSMapViewType.h +3 -0
  25. package/ios/AirGoogleMaps/RCTConvert+GMSMapViewType.m +18 -0
  26. package/ios/AirGoogleMaps/RNMapsGoogleMapView.h +26 -0
  27. package/ios/AirGoogleMaps/RNMapsGoogleMapView.mm +599 -0
  28. package/ios/AirGoogleMaps/RNMapsGoogleMapViewManager.mm +25 -0
  29. package/ios/AirGoogleMaps/RNMapsGooglePolygonView.h +26 -0
  30. package/ios/AirGoogleMaps/RNMapsGooglePolygonView.mm +217 -0
  31. package/ios/AirGoogleMaps/RNMapsGooglePolygonViewManager.mm +25 -0
  32. package/ios/AirMaps/AIRMap.h +8 -4
  33. package/ios/AirMaps/AIRMap.m +226 -101
  34. package/ios/AirMaps/AIRMapManager.m +12 -21
  35. package/ios/AirMaps/AIRMapMarker.h +1 -0
  36. package/ios/AirMaps/AIRMapMarker.m +160 -103
  37. package/ios/AirMaps/Callout/SMCalloutView.m +1 -1
  38. package/ios/AirMaps/RCTConvert+AirMap.h +4 -0
  39. package/ios/AirMaps/RCTConvert+AirMap.m +2 -0
  40. package/ios/AirMaps/RNMapsAirModule.h +3 -0
  41. package/ios/AirMaps/RNMapsAirModule.mm +42 -172
  42. package/ios/AirMaps/RNMapsAirModuleDelegate.h +24 -0
  43. package/ios/AirMaps/RNMapsHostVewDelegate.h +17 -0
  44. package/ios/AirMaps/RNMapsMapView.h +6 -3
  45. package/ios/AirMaps/RNMapsMapView.mm +340 -334
  46. package/ios/AirMaps/RNMapsMarkerView.h +24 -0
  47. package/ios/AirMaps/RNMapsMarkerView.mm +404 -0
  48. package/ios/AirMaps/RNMapsMarkerViewManager.mm +21 -0
  49. package/ios/AirMaps/UIView +AirMap.m +20 -0
  50. package/ios/AirMaps/UIView+AirMap.h +11 -0
  51. package/lib/MapMarker.d.ts +3 -2
  52. package/lib/MapMarker.js +53 -9
  53. package/lib/MapMarkerNativeComponent.js +0 -2
  54. package/lib/MapOverlay.d.ts +1 -1
  55. package/lib/MapView.d.ts +5 -22
  56. package/lib/MapView.js +34 -21
  57. package/lib/{FabricMapView.d.ts → createFabricMap.d.ts} +7 -6
  58. package/lib/createFabricMap.js +175 -0
  59. package/lib/decorateMapComponent.js +18 -0
  60. package/lib/specs/NativeAirMapsModule.d.ts +2 -2
  61. package/lib/specs/NativeComponentGoogleMapView.d.ts +713 -0
  62. package/lib/specs/NativeComponentGoogleMapView.js +21 -0
  63. package/lib/specs/NativeComponentGooglePolygon.d.ts +75 -0
  64. package/lib/specs/NativeComponentGooglePolygon.js +9 -0
  65. package/lib/specs/NativeComponentMapView.d.ts +21 -45
  66. package/lib/specs/NativeComponentMarker.d.ts +246 -0
  67. package/lib/specs/NativeComponentMarker.js +21 -0
  68. package/package.json +7 -7
  69. package/react-native-maps.podspec +1 -1
  70. package/lib/FabricMapView.js +0 -175
@@ -0,0 +1,24 @@
1
+ //
2
+ // RNMapsMarker.h
3
+ // AirMaps
4
+ //
5
+ // Created by Salah Ghanim on 23.11.24.
6
+ // Copyright © 2024 react-native-maps. All rights reserved.
7
+ //
8
+ #ifdef RCT_NEW_ARCH_ENABLED
9
+
10
+ #import <React/RCTViewComponentView.h>
11
+ #import <UIKit/UIKit.h>
12
+
13
+ NS_ASSUME_NONNULL_BEGIN
14
+
15
+ typedef void (^LoadCompletionHandler)(UIView *view);
16
+
17
+ @class AIRMapMarker;
18
+ @interface RNMapsMarkerView : RCTViewComponentView
19
+ - (AIRMapMarker*) marker;
20
+ @end
21
+
22
+ NS_ASSUME_NONNULL_END
23
+
24
+ #endif
@@ -0,0 +1,404 @@
1
+ //
2
+ // RNMapsMarker.m
3
+ // AirMaps
4
+ //
5
+ // Created by Salah Ghanim on 23.11.24.
6
+ // Copyright © 2024 react-native-maps. All rights reserved.
7
+ //
8
+
9
+ #import "RNMapsMarkerView.h"
10
+ #import "AirMap.h"
11
+ #import "AIRMapMarker.h"
12
+ #import "AIRMapMarkerManager.h"
13
+ #import <react/renderer/components/RNMapsSpecs/ComponentDescriptors.h>
14
+ #import <react/renderer/components/RNMapsSpecs/EventEmitters.h>
15
+ #import <react/renderer/components/RNMapsSpecs/Props.h>
16
+ #import <react/renderer/components/RNMapsSpecs/RCTComponentViewHelpers.h>
17
+ #import "RCTFabricComponentsPlugins.h"
18
+ #import <React/RCTConversions.h>
19
+ #import "UIView+AirMap.h"
20
+
21
+ using namespace facebook::react;
22
+
23
+ @interface RNMapsMarkerView () <RCTRNMapsMarkerViewProtocol>
24
+ @end
25
+
26
+ @implementation RNMapsMarkerView {
27
+ AIRMapMarker *_view;
28
+ AIRMapMarkerManager* _legacyMapManager;
29
+ }
30
+
31
+ - (AIRMapMarker *) marker {
32
+ return _view;
33
+ }
34
+ - (void) prepareForRecycle
35
+ {
36
+ [super prepareForRecycle];
37
+ [_view removeFromSuperview];
38
+ _view = nil;
39
+ _legacyMapManager = nil;
40
+ }
41
+
42
+ #pragma mark - JS Commands
43
+
44
+
45
+ #pragma mark - Native commands
46
+
47
+ - (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args
48
+ {
49
+ RCTRNMapsMarkerHandleCommand(self, commandName, args);
50
+ }
51
+
52
+
53
+ + (ComponentDescriptorProvider)componentDescriptorProvider
54
+ {
55
+ return concreteComponentDescriptorProvider<RNMapsMarkerComponentDescriptor>();
56
+ }
57
+
58
+ - (void) animateToCoordinates:(double)latitude longitude:(double)longitude duration:(NSInteger)duration
59
+ {
60
+ [_view animateToCoordinate:CLLocationCoordinate2DMake(latitude, longitude) duration:duration/1000];
61
+ }
62
+
63
+ - (void) showCallout
64
+ {
65
+ [_view.map selectAnnotation:_view animated:YES];
66
+ }
67
+
68
+ - (void) hideCallout
69
+ {
70
+ [_view.map deselectAnnotation:_view animated:YES];
71
+
72
+ }
73
+
74
+ - (void) setCoordinates:(double)latitude longitude:(double)longitude
75
+ {
76
+ [_view setCoordinate:CLLocationCoordinate2DMake(latitude, longitude)];
77
+ }
78
+
79
+
80
+
81
+ - (void) prepareMarkerView
82
+ {
83
+ if (_legacyMapManager && _view) return;
84
+ static const auto defaultProps = std::make_shared<const RNMapsMarkerProps>();
85
+ _props = defaultProps;
86
+ _legacyMapManager = [[AIRMapMarkerManager alloc] init];
87
+ _view = (AIRMapMarker *)[_legacyMapManager view];
88
+
89
+
90
+ _view.onPress = [self](NSDictionary* dictionary) {
91
+ if (_eventEmitter) {
92
+ // Extract values from the NSDictionary
93
+ NSDictionary* coordinateDict = dictionary[@"coordinate"];
94
+ NSDictionary* positionDict = dictionary[@"position"];
95
+
96
+ // Populate the OnCalloutPressPoint struct
97
+ facebook::react::RNMapsMarkerEventEmitter::OnPressPosition point = {
98
+ .x = [coordinateDict[@"x"] doubleValue],
99
+ .y = [coordinateDict[@"y"] doubleValue],
100
+ };
101
+
102
+
103
+ facebook::react::RNMapsMarkerEventEmitter::OnPressCoordinate coordinate = {
104
+ .latitude = [coordinateDict[@"latitude"] doubleValue],
105
+ .longitude = [coordinateDict[@"longitude"] doubleValue],
106
+ };
107
+
108
+ auto eventEmitter = std::static_pointer_cast<RNMapsMarkerEventEmitter const>(_eventEmitter);
109
+ facebook::react::RNMapsMarkerEventEmitter::OnPress data = {
110
+ .action = std::string([dictionary[@"action"] UTF8String]),
111
+ .id = std::string([dictionary[@"id"] UTF8String]),
112
+ .position = point,
113
+ .coordinate = coordinate,
114
+ };
115
+ eventEmitter->onPress(data);
116
+ }
117
+ };
118
+
119
+ _view.onDeselect = [self](NSDictionary* dictionary) {
120
+ if (_eventEmitter) {
121
+ // Extract values from the NSDictionary
122
+ NSDictionary* coordinateDict = dictionary[@"coordinate"];
123
+ NSDictionary* positionDict = dictionary[@"position"];
124
+
125
+ // Populate the OnCalloutPressPoint struct
126
+ facebook::react::RNMapsMarkerEventEmitter::OnDeselectPosition point = {
127
+ .x = [coordinateDict[@"x"] doubleValue],
128
+ .y = [coordinateDict[@"y"] doubleValue],
129
+ };
130
+
131
+
132
+ facebook::react::RNMapsMarkerEventEmitter::OnDeselectCoordinate coordinate = {
133
+ .latitude = [coordinateDict[@"latitude"] doubleValue],
134
+ .longitude = [coordinateDict[@"longitude"] doubleValue],
135
+ };
136
+
137
+ auto eventEmitter = std::static_pointer_cast<RNMapsMarkerEventEmitter const>(_eventEmitter);
138
+ facebook::react::RNMapsMarkerEventEmitter::OnDeselect data = {
139
+ .action = std::string([dictionary[@"action"] UTF8String]),
140
+ .id = std::string([dictionary[@"id"] UTF8String]),
141
+ .position = point,
142
+ .coordinate = coordinate,
143
+ };
144
+ eventEmitter->onDeselect(data);
145
+ }
146
+ };
147
+
148
+ _view.onDrag = [self](NSDictionary* dictionary) {
149
+ if (_eventEmitter) {
150
+ // Extract values from the NSDictionary
151
+ NSDictionary* coordinateDict = dictionary[@"coordinate"];
152
+
153
+
154
+ facebook::react::RNMapsMarkerEventEmitter::OnDragCoordinate coordinate = {
155
+ .latitude = [coordinateDict[@"latitude"] doubleValue],
156
+ .longitude = [coordinateDict[@"longitude"] doubleValue],
157
+ };
158
+
159
+ auto eventEmitter = std::static_pointer_cast<RNMapsMarkerEventEmitter const>(_eventEmitter);
160
+ facebook::react::RNMapsMarkerEventEmitter::OnDrag data = {
161
+ .id = std::string([dictionary[@"id"] UTF8String]),
162
+ .coordinate = coordinate,
163
+ };
164
+ eventEmitter->onDrag(data);
165
+ }
166
+ };
167
+ _view.onDragStart = [self](NSDictionary* dictionary) {
168
+ if (_eventEmitter) {
169
+ // Extract values from the NSDictionary
170
+ NSDictionary* coordinateDict = dictionary[@"coordinate"];
171
+
172
+ facebook::react::RNMapsMarkerEventEmitter::OnDragStartCoordinate coordinate = {
173
+ .latitude = [coordinateDict[@"latitude"] doubleValue],
174
+ .longitude = [coordinateDict[@"longitude"] doubleValue],
175
+ };
176
+
177
+ auto eventEmitter = std::static_pointer_cast<RNMapsMarkerEventEmitter const>(_eventEmitter);
178
+ facebook::react::RNMapsMarkerEventEmitter::OnDragStart data = {
179
+ .id = std::string([dictionary[@"id"] UTF8String]),
180
+ .coordinate = coordinate,
181
+ };
182
+ eventEmitter->onDragStart(data);
183
+ }
184
+ };
185
+
186
+ _view.onDragEnd = [self](NSDictionary* dictionary) {
187
+ if (_eventEmitter) {
188
+ // Extract values from the NSDictionary
189
+ NSDictionary* coordinateDict = dictionary[@"coordinate"];
190
+
191
+
192
+ facebook::react::RNMapsMarkerEventEmitter::OnDragEndCoordinate coordinate = {
193
+ .latitude = [coordinateDict[@"latitude"] doubleValue],
194
+ .longitude = [coordinateDict[@"longitude"] doubleValue],
195
+ };
196
+
197
+ auto eventEmitter = std::static_pointer_cast<RNMapsMarkerEventEmitter const>(_eventEmitter);
198
+ facebook::react::RNMapsMarkerEventEmitter::OnDragEnd data = {
199
+ .id = std::string([dictionary[@"id"] UTF8String]),
200
+ .coordinate = coordinate,
201
+ };
202
+ eventEmitter->onDragEnd(data);
203
+ }
204
+ };
205
+
206
+ _view.onSelect = [self](NSDictionary* dictionary) {
207
+ if (_eventEmitter) {
208
+ // Extract values from the NSDictionary
209
+ NSDictionary* coordinateDict = dictionary[@"coordinate"];
210
+ NSDictionary* positionDict = dictionary[@"position"];
211
+
212
+ // Populate the OnCalloutPressPoint struct
213
+ facebook::react::RNMapsMarkerEventEmitter::OnSelectPosition point = {
214
+ .x = [coordinateDict[@"x"] doubleValue],
215
+ .y = [coordinateDict[@"y"] doubleValue],
216
+ };
217
+
218
+
219
+ facebook::react::RNMapsMarkerEventEmitter::OnSelectCoordinate coordinate = {
220
+ .latitude = [coordinateDict[@"latitude"] doubleValue],
221
+ .longitude = [coordinateDict[@"longitude"] doubleValue],
222
+ };
223
+
224
+ auto eventEmitter = std::static_pointer_cast<RNMapsMarkerEventEmitter const>(_eventEmitter);
225
+ facebook::react::RNMapsMarkerEventEmitter::OnSelect data = {
226
+ .action = std::string([dictionary[@"action"] UTF8String]),
227
+ .id = std::string([dictionary[@"id"] UTF8String]),
228
+ .position = point,
229
+ .coordinate = coordinate,
230
+ };
231
+ eventEmitter->onSelect(data);
232
+ }
233
+ };
234
+
235
+
236
+ _view.onCalloutPress = [self](NSDictionary* dictionary) {
237
+ if (_eventEmitter) {
238
+ // Extract values from the NSDictionary
239
+ NSDictionary* pointDict = dictionary[@"point"];
240
+ NSDictionary* frameDict = dictionary[@"frame"];
241
+
242
+ // Populate the OnCalloutPressPoint struct
243
+ facebook::react::RNMapsMarkerEventEmitter::OnCalloutPressPoint point = {
244
+ .x = [pointDict[@"x"] doubleValue],
245
+ .y = [pointDict[@"y"] doubleValue],
246
+ };
247
+
248
+
249
+ facebook::react::RNMapsMarkerEventEmitter::OnCalloutPressFrame frame = {
250
+ .x = [frameDict[@"x"] doubleValue],
251
+ .y = [frameDict[@"x"] doubleValue],
252
+ .width = [frameDict[@"width"] doubleValue],
253
+ .height = [frameDict[@"height"] doubleValue],
254
+ };
255
+
256
+ auto eventEmitter = std::static_pointer_cast<RNMapsMarkerEventEmitter const>(_eventEmitter);
257
+ facebook::react::RNMapsMarkerEventEmitter::OnCalloutPress data = {
258
+ .action = std::string([dictionary[@"action"] UTF8String]),
259
+ .id = std::string([dictionary[@"id"] UTF8String]),
260
+ .frame = frame,
261
+ .point = point,
262
+ };
263
+ eventEmitter->onCalloutPress(data);
264
+ }
265
+ };
266
+
267
+ }
268
+
269
+ - (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index{
270
+ id<RCTComponent> paperView = [childComponentView getPaperViewFromChildComponentView];
271
+ if (paperView){
272
+ [_view insertReactSubview:paperView atIndex:index];
273
+ } else {
274
+ [_view insertReactSubview:childComponentView atIndex:index];
275
+ }
276
+ }
277
+
278
+ - (void) unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
279
+ {
280
+ id<RCTComponent> paperView = [childComponentView getPaperViewFromChildComponentView];
281
+ if (paperView){
282
+ [_view removeReactSubview:paperView];
283
+ } else {
284
+ [_view removeReactSubview:childComponentView];
285
+ }
286
+ }
287
+ - (instancetype)initWithFrame:(CGRect)frame
288
+ {
289
+ if (self = [super initWithFrame:frame]) {
290
+ [self prepareMarkerView];
291
+ }
292
+
293
+ return self;
294
+ }
295
+
296
+ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
297
+ {
298
+ [self prepareMarkerView];
299
+ const auto &oldViewProps = *std::static_pointer_cast<RNMapsMarkerProps const>(_props);
300
+ const auto &newViewProps = *std::static_pointer_cast<RNMapsMarkerProps const>(props);
301
+ BOOL completionHandlerCalled = false;
302
+
303
+ #define REMAP_MAPVIEW_PROP(name) \
304
+ if (oldViewProps.name != newViewProps.name) { \
305
+ _view.name = newViewProps.name; \
306
+ }
307
+
308
+ #define REMAP_MAPVIEW_STRING_PROP(name) \
309
+ if (oldViewProps.name != newViewProps.name) { \
310
+ _view.name = RCTNSStringFromString(newViewProps.name); \
311
+ }
312
+
313
+ #define REMAP_MAPVIEW_COLOR_PROP(name) \
314
+ if (oldViewProps.name != newViewProps.name) { \
315
+ _view.name = RCTUIColorFromSharedColor(newViewProps.name); \
316
+ }
317
+
318
+ #define REMAP_MAPVIEW_POINT_PROP(name) \
319
+ if (newViewProps.name.x != oldViewProps.name.x || \
320
+ newViewProps.name.y != oldViewProps.name.y) { \
321
+ _view.name = CGPointMake(newViewProps.name.x, newViewProps.name.y); \
322
+ }
323
+
324
+ if (newViewProps.zIndex != oldViewProps.zIndex){
325
+ if (newViewProps.zIndex.has_value()){
326
+ _view.zIndex = newViewProps.zIndex.value();
327
+ } else {
328
+ // default
329
+ _view.zIndex = 0;
330
+ }
331
+ }
332
+ if (newViewProps.image != oldViewProps.image){
333
+ if (newViewProps.image.uri.size()){
334
+ [_view setImageSrc:RCTNSStringFromString(newViewProps.image.uri)];
335
+ completionHandlerCalled = true;
336
+ } else {
337
+ [_view setImageSrc:nil];
338
+ }
339
+ }
340
+
341
+ REMAP_MAPVIEW_PROP(useLegacyPinView)
342
+
343
+
344
+ REMAP_MAPVIEW_PROP(opacity)
345
+ REMAP_MAPVIEW_PROP(draggable)
346
+ REMAP_MAPVIEW_PROP(isPreselected)
347
+
348
+ REMAP_MAPVIEW_COLOR_PROP(pinColor)
349
+
350
+
351
+ REMAP_MAPVIEW_POINT_PROP(calloutOffset)
352
+ if (newViewProps.coordinate.latitude != oldViewProps.coordinate.latitude ||
353
+ newViewProps.coordinate.longitude != oldViewProps.coordinate.longitude) {
354
+ CLLocationCoordinate2D coordinates = CLLocationCoordinate2DMake(
355
+ newViewProps.coordinate.latitude,
356
+ newViewProps.coordinate.longitude);
357
+ _view.coordinate = coordinates;
358
+ }
359
+
360
+
361
+ if (newViewProps.description != oldViewProps.description){
362
+ _view.subtitle = RCTNSStringFromString(newViewProps.description);
363
+ }
364
+ REMAP_MAPVIEW_STRING_PROP(title)
365
+ REMAP_MAPVIEW_STRING_PROP(identifier)
366
+ if (newViewProps.titleVisibility != oldViewProps.titleVisibility){
367
+ switch (newViewProps.titleVisibility) {
368
+ case RNMapsMarkerTitleVisibility::Visible:
369
+ [_view setTitleVisibility:MKFeatureVisibilityVisible];
370
+ break;
371
+ case RNMapsMarkerTitleVisibility::Adaptive:
372
+ [_view setTitleVisibility:MKFeatureVisibilityAdaptive];
373
+ break;
374
+ case RNMapsMarkerTitleVisibility::Hidden:
375
+ [_view setTitleVisibility:MKFeatureVisibilityHidden];
376
+ break;
377
+ }
378
+ }
379
+ if (newViewProps.subtitleVisibility != oldViewProps.subtitleVisibility){
380
+ switch (newViewProps.subtitleVisibility) {
381
+ case RNMapsMarkerSubtitleVisibility::Visible:
382
+ [_view setSubtitleVisibility:MKFeatureVisibilityVisible];
383
+ break;
384
+ case RNMapsMarkerSubtitleVisibility::Adaptive:
385
+ [_view setSubtitleVisibility:MKFeatureVisibilityAdaptive];
386
+ break;
387
+ case RNMapsMarkerSubtitleVisibility::Hidden:
388
+ [_view setSubtitleVisibility:MKFeatureVisibilityHidden];
389
+ break;
390
+
391
+ }
392
+ }
393
+
394
+
395
+ [super updateProps:props oldProps:oldProps];
396
+ }
397
+
398
+
399
+ @end
400
+
401
+ Class<RCTComponentViewProtocol> RNMapsMarkerCls(void)
402
+ {
403
+ return RNMapsMarkerView.class;
404
+ }
@@ -0,0 +1,21 @@
1
+ //
2
+ // RNMapsMarkerManager.m
3
+ // AirMaps
4
+ //
5
+ // Created by Salah Ghanim on 23.11.24.
6
+ // Copyright © 2024 react-native-maps. All rights reserved.
7
+ //
8
+
9
+ #import <React/RCTLog.h>
10
+ #import <React/RCTUIManager.h>
11
+ #import <React/RCTViewManager.h>
12
+
13
+ @interface RNMapsMarkerViewManager : RCTViewManager
14
+ @end
15
+
16
+ @implementation RNMapsMarkerViewManager
17
+
18
+ RCT_EXPORT_MODULE(RNMapsMarkerViewManager)
19
+
20
+
21
+ @end
@@ -0,0 +1,20 @@
1
+ //
2
+ // Created by Leland Richardson on 12/27/15.
3
+ // Copyright (c) 2015 Facebook. All rights reserved.
4
+ //
5
+
6
+ #import "UIView+AirMap.h"
7
+
8
+ @implementation UIView (AirMap)
9
+
10
+ - (UIView *) getPaperViewFromChildComponentView {
11
+ // Check if the childComponentView responds to the "adapter" selector
12
+ if ([self respondsToSelector:@selector(paperView)]) {
13
+ // Safely return the paperView
14
+ return [self valueForKey:@"paperView"];
15
+ }
16
+ // Return nil if paperView is not accessible
17
+ return nil;
18
+ }
19
+
20
+ @end
@@ -0,0 +1,11 @@
1
+ //
2
+ // Created by Salah Ghanim on 29/12/2024.
3
+ // Copyright (c) 2015 Facebook. All rights reserved.
4
+ //
5
+
6
+ #import <UIKit/UIKit.h>
7
+
8
+ @interface UIView (AirMap)
9
+ - (UIView *) getPaperViewFromChildComponentView;
10
+
11
+ @end
@@ -42,7 +42,7 @@ export type MapMarkerProps = ViewProps & {
42
42
  *
43
43
  * @default {x: 0.0, y: 0.0}
44
44
  * @platform iOS: Apple Maps only. For Google Maps, see the `calloutAnchor` prop
45
- * @platform Android: Not supported. See see the `calloutAnchor` prop
45
+ * @platform Android: Not supported. see the `calloutAnchor` prop
46
46
  */
47
47
  calloutOffset?: Point;
48
48
  /**
@@ -54,7 +54,7 @@ export type MapMarkerProps = ViewProps & {
54
54
  *
55
55
  * @default {x: 0.0, y: 0.0}
56
56
  * @platform iOS: Apple Maps only. For Google Maps, see the `anchor` prop
57
- * @platform Android: Not supported. See see the `anchor` prop
57
+ * @platform Android: Not supported. see the `anchor` prop
58
58
  */
59
59
  centerOffset?: Point;
60
60
  /**
@@ -295,6 +295,7 @@ export declare class MapMarker extends React.Component<MapMarkerProps> {
295
295
  getUIManagerCommand: (name: string) => UIManagerCommand;
296
296
  static Animated: Animated.AnimatedComponent<typeof MapMarker>;
297
297
  private marker;
298
+ private fabricMarker?;
298
299
  constructor(props: MapMarkerProps);
299
300
  setNativeProps(props: Partial<NativeProps>): void;
300
301
  showCallout(): void;
package/lib/MapMarker.js CHANGED
@@ -28,12 +28,15 @@ const React = __importStar(require("react"));
28
28
  const react_native_1 = require("react-native");
29
29
  const decorateMapComponent_1 = __importStar(require("./decorateMapComponent"));
30
30
  const MapMarkerNativeComponent_1 = require("./MapMarkerNativeComponent");
31
+ const NativeComponentMarker_1 = require("./specs/NativeComponentMarker");
32
+ const ProviderConstants_1 = require("./ProviderConstants");
31
33
  class MapMarker extends React.Component {
32
34
  getNativeComponent;
33
35
  getMapManagerCommand;
34
36
  getUIManagerCommand;
35
37
  static Animated;
36
38
  marker;
39
+ fabricMarker = undefined;
37
40
  constructor(props) {
38
41
  super(props);
39
42
  this.marker = React.createRef();
@@ -49,27 +52,59 @@ class MapMarker extends React.Component {
49
52
  }
50
53
  showCallout() {
51
54
  if (this.marker.current) {
52
- MapMarkerNativeComponent_1.Commands.showCallout(this.marker.current);
55
+ if (this.fabricMarker) {
56
+ // @ts-ignore
57
+ NativeComponentMarker_1.Commands.showCallout(this.marker.current);
58
+ }
59
+ else {
60
+ MapMarkerNativeComponent_1.Commands.showCallout(this.marker.current);
61
+ }
53
62
  }
54
63
  }
55
64
  hideCallout() {
56
65
  if (this.marker.current) {
57
- MapMarkerNativeComponent_1.Commands.hideCallout(this.marker.current);
66
+ if (this.fabricMarker) {
67
+ // @ts-ignore
68
+ NativeComponentMarker_1.Commands.hideCallout(this.marker.current);
69
+ }
70
+ else {
71
+ MapMarkerNativeComponent_1.Commands.hideCallout(this.marker.current);
72
+ }
58
73
  }
59
74
  }
60
75
  setCoordinates(coordinate) {
61
76
  if (this.marker.current) {
62
- MapMarkerNativeComponent_1.Commands.setCoordinates(this.marker.current, coordinate);
77
+ if (this.fabricMarker) {
78
+ NativeComponentMarker_1.Commands.setCoordinates(
79
+ // @ts-ignore
80
+ this.marker.current, coordinate.latitude, coordinate.longitude);
81
+ }
82
+ else {
83
+ MapMarkerNativeComponent_1.Commands.setCoordinates(this.marker.current, coordinate);
84
+ }
63
85
  }
64
86
  }
65
87
  redrawCallout() {
66
88
  if (this.marker.current) {
67
- MapMarkerNativeComponent_1.Commands.redrawCallout(this.marker.current);
89
+ if (this.fabricMarker) {
90
+ // @ts-ignore
91
+ NativeComponentMarker_1.Commands.redrawCallout(this.marker.current);
92
+ }
93
+ else {
94
+ MapMarkerNativeComponent_1.Commands.redrawCallout(this.marker.current);
95
+ }
68
96
  }
69
97
  }
70
98
  animateMarkerToCoordinate(coordinate, duration = 500) {
71
99
  if (this.marker.current) {
72
- MapMarkerNativeComponent_1.Commands.animateMarkerToCoordinate(this.marker.current, coordinate, duration);
100
+ if (this.fabricMarker) {
101
+ NativeComponentMarker_1.Commands.animateToCoordinates(
102
+ // @ts-ignore
103
+ this.marker.current, coordinate.latitude, coordinate.longitude, duration);
104
+ }
105
+ else {
106
+ MapMarkerNativeComponent_1.Commands.animateMarkerToCoordinate(this.marker.current, coordinate, duration);
107
+ }
73
108
  }
74
109
  }
75
110
  redraw() {
@@ -79,10 +114,9 @@ class MapMarker extends React.Component {
79
114
  }
80
115
  render() {
81
116
  const { stopPropagation = false } = this.props;
82
- let image;
83
- if (this.props.image) {
84
- image = react_native_1.Image.resolveAssetSource(this.props.image) || {};
85
- image = image.uri || this.props.image;
117
+ if (this.fabricMarker === undefined) {
118
+ const provider = this.context;
119
+ this.fabricMarker = provider !== ProviderConstants_1.PROVIDER_GOOGLE && react_native_1.Platform.OS === 'ios';
86
120
  }
87
121
  let icon;
88
122
  if (this.props.icon) {
@@ -90,6 +124,16 @@ class MapMarker extends React.Component {
90
124
  icon = icon.uri;
91
125
  }
92
126
  const AIRMapMarker = this.getNativeComponent();
127
+ let image;
128
+ if (this.props.image) {
129
+ if (this.fabricMarker) {
130
+ image = this.props.image;
131
+ }
132
+ else {
133
+ image = react_native_1.Image.resolveAssetSource(this.props.image) || {};
134
+ image = image.uri || this.props.image;
135
+ }
136
+ }
93
137
  return (<AIRMapMarker {...this.props} ref={this.marker} image={image} icon={icon} style={[styles.marker, this.props.style]} onPress={event => {
94
138
  if (stopPropagation) {
95
139
  event.stopPropagation();
@@ -9,9 +9,7 @@ exports.Commands = (0, codegenNativeCommands_1.default)({
9
9
  supportedCommands: [
10
10
  'showCallout',
11
11
  'hideCallout',
12
- 'redrawCallout',
13
12
  'animateMarkerToCoordinate',
14
- 'redraw',
15
13
  'setCoordinates',
16
14
  ],
17
15
  });
@@ -70,7 +70,7 @@ type OverlayPressEvent = NativeSyntheticEvent<{
70
70
  */
71
71
  action: 'overlay-press' | 'image-overlay-press';
72
72
  /**
73
- * @platform iOS: Apple maps
73
+ * @platform iOS: Apple Maps
74
74
  */
75
75
  name?: string;
76
76
  /**