react-native-maps 1.21.0-alpha.4 → 1.21.0-alpha.41

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 (69) hide show
  1. package/android/src/main/java/com/rnmaps/fabric/NativeAirMapsModule.java +51 -0
  2. package/android/src/main/java/com/rnmaps/maps/MapAirModulePackage.java +46 -0
  3. package/ios/AirGoogleMaps/AIRGoogleMap.h +8 -2
  4. package/ios/AirGoogleMaps/AIRGoogleMap.m +179 -11
  5. package/ios/AirGoogleMaps/AIRGoogleMapCircle.h +0 -1
  6. package/ios/AirGoogleMaps/AIRGoogleMapCircle.m +23 -11
  7. package/ios/AirGoogleMaps/AIRGoogleMapCoordinate.h +13 -0
  8. package/ios/AirGoogleMaps/AIRGoogleMapCoordinate.m +10 -0
  9. package/ios/AirGoogleMaps/AIRGoogleMapManager.h +7 -0
  10. package/ios/AirGoogleMaps/AIRGoogleMapManager.m +30 -119
  11. package/ios/AirGoogleMaps/AIRGoogleMapMarker.h +2 -0
  12. package/ios/AirGoogleMaps/AIRGoogleMapMarker.m +347 -243
  13. package/ios/AirGoogleMaps/AIRGoogleMapMarkerManager.m +0 -1
  14. package/ios/AirGoogleMaps/AIRGoogleMapOverlay.h +0 -1
  15. package/ios/AirGoogleMaps/AIRGoogleMapPolygon.h +5 -4
  16. package/ios/AirGoogleMaps/AIRGoogleMapPolygon.m +32 -2
  17. package/ios/AirGoogleMaps/AIRGoogleMapPolygonManager.m +3 -3
  18. package/ios/AirGoogleMaps/AIRGoogleMapPolyline.h +3 -2
  19. package/ios/AirGoogleMaps/AIRGoogleMapPolyline.m +2 -3
  20. package/ios/AirGoogleMaps/AIRGoogleMapPolylineManager.m +2 -2
  21. package/ios/AirGoogleMaps/AIRGoogleMapWMSTile.h +1 -1
  22. package/ios/AirGoogleMaps/AIRGoogleMapWMSTile.m +2 -2
  23. package/ios/AirGoogleMaps/RCTConvert+GMSMapViewType.h +3 -0
  24. package/ios/AirGoogleMaps/RCTConvert+GMSMapViewType.m +18 -0
  25. package/ios/AirGoogleMaps/RNMapsGoogleMapView.h +26 -0
  26. package/ios/AirGoogleMaps/RNMapsGoogleMapView.mm +599 -0
  27. package/ios/AirGoogleMaps/RNMapsGoogleMapViewManager.mm +25 -0
  28. package/ios/AirGoogleMaps/RNMapsGooglePolygonView.h +26 -0
  29. package/ios/AirGoogleMaps/RNMapsGooglePolygonView.mm +217 -0
  30. package/ios/AirGoogleMaps/RNMapsGooglePolygonViewManager.mm +25 -0
  31. package/ios/AirMaps/AIRMap.h +8 -5
  32. package/ios/AirMaps/AIRMap.m +284 -141
  33. package/ios/AirMaps/AIRMapManager.m +12 -21
  34. package/ios/AirMaps/AIRMapMarker.h +1 -0
  35. package/ios/AirMaps/AIRMapMarker.m +165 -103
  36. package/ios/AirMaps/Callout/SMCalloutView.m +1 -1
  37. package/ios/AirMaps/RCTConvert+AirMap.h +4 -0
  38. package/ios/AirMaps/RCTConvert+AirMap.m +2 -0
  39. package/ios/AirMaps/RNMapsAirModule.h +3 -0
  40. package/ios/AirMaps/RNMapsAirModule.mm +42 -172
  41. package/ios/AirMaps/RNMapsAirModuleDelegate.h +24 -0
  42. package/ios/AirMaps/RNMapsHostVewDelegate.h +17 -0
  43. package/ios/AirMaps/RNMapsMapView.h +6 -3
  44. package/ios/AirMaps/RNMapsMapView.mm +341 -334
  45. package/ios/AirMaps/RNMapsMarkerView.h +24 -0
  46. package/ios/AirMaps/RNMapsMarkerView.mm +422 -0
  47. package/ios/AirMaps/RNMapsMarkerViewManager.mm +21 -0
  48. package/ios/AirMaps/UIView +AirMap.m +20 -0
  49. package/ios/AirMaps/UIView+AirMap.h +11 -0
  50. package/lib/MapMarker.d.ts +15 -2
  51. package/lib/MapMarker.js +53 -9
  52. package/lib/MapMarkerNativeComponent.js +0 -2
  53. package/lib/MapOverlay.d.ts +1 -1
  54. package/lib/MapView.d.ts +5 -22
  55. package/lib/MapView.js +34 -21
  56. package/lib/{FabricMapView.d.ts → createFabricMap.d.ts} +7 -6
  57. package/lib/createFabricMap.js +175 -0
  58. package/lib/decorateMapComponent.js +18 -0
  59. package/lib/specs/NativeAirMapsModule.d.ts +2 -2
  60. package/lib/specs/NativeComponentGoogleMapView.d.ts +713 -0
  61. package/lib/specs/NativeComponentGoogleMapView.js +21 -0
  62. package/lib/specs/NativeComponentGooglePolygon.d.ts +75 -0
  63. package/lib/specs/NativeComponentGooglePolygon.js +9 -0
  64. package/lib/specs/NativeComponentMapView.d.ts +21 -45
  65. package/lib/specs/NativeComponentMarker.d.ts +258 -0
  66. package/lib/specs/NativeComponentMarker.js +21 -0
  67. package/package.json +7 -7
  68. package/react-native-maps.podspec +1 -1
  69. package/lib/FabricMapView.js +0 -175
@@ -0,0 +1,599 @@
1
+ //
2
+ // RNMapsGoogleMapView.mm
3
+ //
4
+ //
5
+ // Created by Salah Ghanim on 23.11.24.
6
+ // Copyright © 2024 react-native-maps. All rights reserved.
7
+ //
8
+ #ifdef HAVE_GOOGLE_MAPS
9
+
10
+ #import "RNMapsGoogleMapView.h"
11
+ #import "RNMapsGooglePolygonView.h"
12
+ #import "AirGoogleMap.h"
13
+ #import "AIRMapMarker.h"
14
+ #import "AirGoogleMapManager.h"
15
+
16
+ #import <react/renderer/components/RNMapsSpecs/ComponentDescriptors.h>
17
+ #import <react/renderer/components/RNMapsSpecs/EventEmitters.h>
18
+ #import <react/renderer/components/RNMapsSpecs/Props.h>
19
+ #import <react/renderer/components/RNMapsSpecs/RCTComponentViewHelpers.h>
20
+
21
+ #import "RCTFabricComponentsPlugins.h"
22
+ #import <React/RCTConversions.h>
23
+ #import "RCTConvert+GMSMapViewType.h"
24
+ #import "RCTConvert+AirMap.h"
25
+ #import "UIView+AirMap.h"
26
+
27
+ using namespace facebook::react;
28
+
29
+ @interface RNMapsGoogleMapView () <RCTRNMapsGoogleMapViewViewProtocol>
30
+ @end
31
+
32
+ @implementation RNMapsGoogleMapView {
33
+ AIRGoogleMap *_view;
34
+ AIRGoogleMapManager* _legacyMapManager;
35
+ NSMutableDictionary<NSNumber*, UIView*>* _pendingInsertsSubviews;
36
+ NSMutableArray *_polygons;
37
+ }
38
+
39
+
40
+ - (id<RNMapsAirModuleDelegate>) mapView {
41
+ return _view;
42
+ }
43
+
44
+ #pragma mark - JS Commands
45
+ - (void)animateToRegion:(NSString *)regionJSON duration:(NSInteger)duration{
46
+ NSDictionary* regionDic = [RCTConvert dictonaryFromString:regionJSON];
47
+ MKCoordinateRegion region = [RCTConvert MKCoordinateRegion:regionDic];
48
+ GMSCameraPosition *camera = [AIRGoogleMap makeGMSCameraPositionFromMap:_view andMKCoordinateRegion:region];
49
+ if (duration == 0){
50
+ [_view setRegion:region];
51
+ } else {
52
+ [_view animateToCameraPosition:camera];
53
+ }
54
+ }
55
+ - (void)setCamera:(NSString *)cameraJSON{
56
+ NSDictionary* cameraDic = [RCTConvert dictonaryFromString:cameraJSON];
57
+ GMSCameraPosition* camera = [RCTConvert GMSCameraPositionWithDefaults:cameraDic existingCamera:[_view camera]];
58
+ [_view setCamera:camera];
59
+ }
60
+
61
+ - (void)animateCamera:(NSString *)cameraJSON duration:(NSInteger)duration{
62
+ NSDictionary* cameraDic = [RCTConvert dictonaryFromString:cameraJSON];
63
+ GMSCameraPosition* camera = [RCTConvert GMSCameraPositionWithDefaults:cameraDic existingCamera:[_view camera]];
64
+ [_view animateToCameraPosition:camera];
65
+ }
66
+
67
+ - (void)fitToElements:(NSString *)edgePaddingJSON animated:(BOOL)animated {
68
+ NSDictionary* edgePadding = [RCTConvert dictonaryFromString:edgePaddingJSON];
69
+ [_view fitToElementsWithEdgePadding:edgePadding animated:animated];
70
+ }
71
+
72
+ - (void)fitToSuppliedMarkers:(NSString *)markersJSON edgePaddingJSON:(NSString *)edgePaddingJSON animated:(BOOL)animated {
73
+ NSArray* markers = [RCTConvert arrayFromString:markersJSON];
74
+ NSDictionary* edgePadding = [RCTConvert dictonaryFromString:edgePaddingJSON];
75
+ [_view fitToSuppliedMarkers:markers withEdgePadding:edgePadding animated:animated];
76
+
77
+ }
78
+ - (void)fitToCoordinates:(NSString *)coordinatesJSON edgePaddingJSON:(NSString *)edgePaddingJSON animated:(BOOL)animated {
79
+ NSArray* coordinatesArr = [RCTConvert arrayFromString:coordinatesJSON];
80
+ NSMutableArray<AIRGoogleMapCoordinate*>* coordinatesArray = [NSMutableArray new];
81
+ for (id json : coordinatesArr){
82
+ [coordinatesArray addObject:[RCTConvert AIRGoogleMapCoordinate:json]];
83
+ }
84
+
85
+ NSDictionary* edgePadding = [RCTConvert dictonaryFromString:edgePaddingJSON];
86
+
87
+ [_view fitToCoordinates:coordinatesArray withEdgePadding:edgePadding animated:animated];
88
+ }
89
+
90
+ #pragma mark - Native commands
91
+
92
+ - (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args
93
+ {
94
+ RCTRNMapsGoogleMapViewHandleCommand(self, commandName, args);
95
+ }
96
+
97
+
98
+ + (ComponentDescriptorProvider)componentDescriptorProvider
99
+ {
100
+ return concreteComponentDescriptorProvider<RNMapsGoogleMapViewComponentDescriptor>();
101
+ }
102
+ - (void) loadPendingInsertSubviews
103
+ {
104
+ if ([_pendingInsertsSubviews count] > 0){
105
+ NSArray<NSNumber *> *sortedKeys = [[_pendingInsertsSubviews allKeys] sortedArrayUsingSelector:@selector(compare:)];
106
+ for (NSNumber *key in sortedKeys) {
107
+ // Get the corresponding view
108
+ UIView *view = [_pendingInsertsSubviews objectForKey:key];
109
+ [_view insertReactSubview:view atIndex:[key integerValue]];
110
+ // Remove the entry from the dictionary
111
+ [_pendingInsertsSubviews removeObjectForKey:key];
112
+ }
113
+ }
114
+ }
115
+
116
+ - (void) prepareContentView {
117
+
118
+ _view = (AIRGoogleMap *)[_legacyMapManager view];
119
+ _polygons = [NSMutableArray new];
120
+
121
+ self.contentView = _view;
122
+
123
+ _view.onPress = [self](NSDictionary* dictionary) {
124
+ if (_eventEmitter) {
125
+ // Extract values from the NSDictionary
126
+ NSDictionary* coordinateDict = dictionary[@"coordinate"];
127
+ NSDictionary* positionDict = dictionary[@"position"];
128
+
129
+ // Populate the OnMapPressCoordinate struct
130
+ facebook::react::RNMapsGoogleMapViewEventEmitter::OnPressCoordinate coordinate = {
131
+ .latitude = [coordinateDict[@"latitude"] doubleValue],
132
+ .longitude = [coordinateDict[@"longitude"] doubleValue],
133
+ };
134
+
135
+ // Populate the OnMapPressPosition struct
136
+ facebook::react::RNMapsGoogleMapViewEventEmitter::OnPressPosition position = {
137
+ .x = [positionDict[@"x"] doubleValue],
138
+ .y = [positionDict[@"y"] doubleValue],
139
+ };
140
+
141
+ auto mapViewEventEmitter = std::static_pointer_cast<RNMapsGoogleMapViewEventEmitter const>(_eventEmitter);
142
+ facebook::react::RNMapsGoogleMapViewEventEmitter::OnPress data = {
143
+ .action = std::string([@"press" UTF8String]),
144
+ .position = position,
145
+ .coordinate = coordinate
146
+ };
147
+ mapViewEventEmitter->onPress(data);
148
+ }
149
+ };
150
+
151
+ _view.onLongPress = [self](NSDictionary* dictionary) {
152
+ if (_eventEmitter) {
153
+ // Extract values from the NSDictionary
154
+ NSDictionary* coordinateDict = dictionary[@"coordinate"];
155
+ NSDictionary* positionDict = dictionary[@"position"];
156
+
157
+ // Populate the OnMapPressCoordinate struct
158
+ facebook::react::RNMapsGoogleMapViewEventEmitter::OnLongPressCoordinate coordinate = {
159
+ .latitude = [coordinateDict[@"latitude"] doubleValue],
160
+ .longitude = [coordinateDict[@"longitude"] doubleValue],
161
+ };
162
+
163
+ // Populate the OnMapPressPosition struct
164
+ facebook::react::RNMapsGoogleMapViewEventEmitter::OnLongPressPosition position = {
165
+ .x = [positionDict[@"x"] doubleValue],
166
+ .y = [positionDict[@"y"] doubleValue],
167
+ };
168
+
169
+ auto mapViewEventEmitter = std::static_pointer_cast<RNMapsGoogleMapViewEventEmitter const>(_eventEmitter);
170
+ facebook::react::RNMapsGoogleMapViewEventEmitter::OnLongPress data = {
171
+ .action = std::string([@"press" UTF8String]),
172
+ .position = position,
173
+ .coordinate = coordinate
174
+ };
175
+ mapViewEventEmitter->onLongPress(data);
176
+ }
177
+ };
178
+
179
+ _view.onMapReady = [self](NSDictionary* dictionary) {
180
+ [self loadPendingInsertSubviews];
181
+ if (_eventEmitter) {
182
+ auto mapViewEventEmitter = std::static_pointer_cast<RNMapsGoogleMapViewEventEmitter const>(_eventEmitter);
183
+ facebook::react::RNMapsGoogleMapViewEventEmitter::OnMapReady data = {};
184
+ mapViewEventEmitter->onMapReady(data);
185
+ }
186
+ };
187
+
188
+ _view.onMapLoaded = [self](NSDictionary* dictionary) {
189
+ if (_eventEmitter) {
190
+ auto mapViewEventEmitter = std::static_pointer_cast<RNMapsGoogleMapViewEventEmitter const>(_eventEmitter);
191
+ facebook::react::RNMapsGoogleMapViewEventEmitter::OnMapLoaded data = {};
192
+ mapViewEventEmitter->onMapLoaded(data);
193
+ }
194
+ };
195
+
196
+ _view.onKmlReady = [self](NSDictionary* dictionary) {
197
+ if (_eventEmitter) {
198
+
199
+ auto mapViewEventEmitter = std::static_pointer_cast<RNMapsGoogleMapViewEventEmitter const>(_eventEmitter);
200
+ facebook::react::RNMapsGoogleMapViewEventEmitter::OnKmlReady data = {};
201
+ mapViewEventEmitter->onKmlReady(data);
202
+ }
203
+ };
204
+ _view.onChange = [self](NSDictionary* dictionary) {
205
+ if (_eventEmitter) {
206
+
207
+ NSDictionary* regionDict = dictionary[@"region"];
208
+ auto mapViewEventEmitter = std::static_pointer_cast<RNMapsGoogleMapViewEventEmitter const>(_eventEmitter);
209
+ facebook::react::RNMapsGoogleMapViewEventEmitter::OnRegionChange data = {
210
+ .region.latitude = [regionDict[@"latitude"] doubleValue],
211
+ .region.longitude = [regionDict[@"longitude"] doubleValue],
212
+ .region.latitudeDelta = [regionDict[@"latitudeDelta"] doubleValue],
213
+ .region.longitudeDelta = [regionDict[@"longitudeDelta"] doubleValue],
214
+ .continuous = [dictionary[@"continuous"] boolValue],
215
+ };
216
+ mapViewEventEmitter->onRegionChange(data);
217
+ }
218
+ };
219
+
220
+ _view.onPanDrag = [self](NSDictionary* dictionary) {
221
+ if (_eventEmitter) {
222
+
223
+ NSDictionary* coordinateDict = dictionary[@"coordinate"];
224
+ NSDictionary* positionDict = dictionary[@"position"];
225
+
226
+ // Populate the OnMapPressCoordinate struct
227
+ facebook::react::RNMapsGoogleMapViewEventEmitter::OnPanDragCoordinate coordinate = {
228
+ .latitude = [coordinateDict[@"latitude"] doubleValue],
229
+ .longitude = [coordinateDict[@"longitude"] doubleValue],
230
+ };
231
+
232
+ // Populate the OnMapDouplePressPosition struct
233
+ facebook::react::RNMapsGoogleMapViewEventEmitter::OnPanDragPosition position = {
234
+ .x = [positionDict[@"x"] doubleValue],
235
+ .y = [positionDict[@"y"] doubleValue],
236
+ };
237
+
238
+ auto mapViewEventEmitter = std::static_pointer_cast<RNMapsGoogleMapViewEventEmitter const>(_eventEmitter);
239
+ facebook::react::RNMapsGoogleMapViewEventEmitter::OnPanDrag data = {
240
+ .position = position,
241
+ .coordinate = coordinate,
242
+ };
243
+ mapViewEventEmitter->onPanDrag(data);
244
+ }
245
+ };
246
+
247
+ _view.onUserLocationChange = [self](NSDictionary* dictionary) {
248
+ if (_eventEmitter) {
249
+
250
+ NSDictionary* coordinateDict = dictionary[@"coordinate"];
251
+ NSDictionary* errorDict = dictionary[@"error"];
252
+
253
+
254
+ // Populate the OnMapPressCoordinate struct
255
+ facebook::react::RNMapsGoogleMapViewEventEmitter::OnUserLocationChangeCoordinate coordinate = {
256
+ .latitude = [coordinateDict[@"latitude"] doubleValue],
257
+ .longitude = [coordinateDict[@"longitude"] doubleValue],
258
+ };
259
+ NSString* str = @"";
260
+ if (errorDict){
261
+ str = errorDict[@"message"];
262
+ }
263
+
264
+ facebook::react::RNMapsGoogleMapViewEventEmitter::OnUserLocationChangeError error = {
265
+ .message = std::string([str UTF8String]),
266
+ };
267
+
268
+
269
+ auto mapViewEventEmitter = std::static_pointer_cast<RNMapsGoogleMapViewEventEmitter const>(_eventEmitter);
270
+ facebook::react::RNMapsGoogleMapViewEventEmitter::OnUserLocationChange data = {
271
+ .coordinate = coordinate,
272
+ .error = error,
273
+ };
274
+ mapViewEventEmitter->onUserLocationChange(data);
275
+ }
276
+ };
277
+
278
+
279
+
280
+ _view.onRegionChangeStart = [self](NSDictionary* dictionary) {
281
+ if (_eventEmitter) {
282
+
283
+ NSDictionary* regionDict = dictionary[@"region"];
284
+ auto mapViewEventEmitter = std::static_pointer_cast<RNMapsGoogleMapViewEventEmitter const>(_eventEmitter);
285
+ facebook::react::RNMapsGoogleMapViewEventEmitter::OnRegionChangeStart data = {
286
+ .region.latitude = [regionDict[@"latitude"] doubleValue],
287
+ .region.longitude = [regionDict[@"longitude"] doubleValue],
288
+ .region.latitudeDelta = [regionDict[@"latitudeDelta"] doubleValue],
289
+ .region.longitudeDelta = [regionDict[@"longitudeDelta"] doubleValue],
290
+ .continuous = [dictionary[@"continuous"] boolValue],
291
+ };
292
+ mapViewEventEmitter->onRegionChangeStart(data);
293
+ }
294
+ };
295
+
296
+ _view.onRegionChange = [self](NSDictionary* dictionary) {
297
+ if (_eventEmitter) {
298
+
299
+ NSDictionary* regionDict = dictionary[@"region"];
300
+ auto mapViewEventEmitter = std::static_pointer_cast<RNMapsGoogleMapViewEventEmitter const>(_eventEmitter);
301
+ facebook::react::RNMapsGoogleMapViewEventEmitter::OnRegionChange data = {
302
+ .region.latitude = [regionDict[@"latitude"] doubleValue],
303
+ .region.longitude = [regionDict[@"longitude"] doubleValue],
304
+ .region.latitudeDelta = [regionDict[@"latitudeDelta"] doubleValue],
305
+ .region.longitudeDelta = [regionDict[@"longitudeDelta"] doubleValue],
306
+ .continuous = [dictionary[@"continuous"] boolValue],
307
+ };
308
+ mapViewEventEmitter->onRegionChange(data);
309
+ }
310
+ };
311
+
312
+ _view.onRegionChangeComplete = [self](NSDictionary* dictionary) {
313
+ if (_eventEmitter) {
314
+
315
+ NSDictionary* regionDict = dictionary[@"region"];
316
+ auto mapViewEventEmitter = std::static_pointer_cast<RNMapsGoogleMapViewEventEmitter const>(_eventEmitter);
317
+ facebook::react::RNMapsGoogleMapViewEventEmitter::OnRegionChangeComplete data = {
318
+ .region.latitude = [regionDict[@"latitude"] doubleValue],
319
+ .region.longitude = [regionDict[@"longitude"] doubleValue],
320
+ .region.latitudeDelta = [regionDict[@"latitudeDelta"] doubleValue],
321
+ .region.longitudeDelta = [regionDict[@"longitudeDelta"] doubleValue],
322
+ .continuous = [dictionary[@"continuous"] boolValue],
323
+ };
324
+ mapViewEventEmitter->onRegionChangeComplete(data);
325
+ }
326
+ };
327
+
328
+
329
+ #define HANDLE_MARKER_DRAG_EVENT(eventName, emitterFunction) \
330
+ if (_eventEmitter) { \
331
+ NSDictionary* coordinateDict = dictionary[@"coordinate"]; \
332
+ auto mapViewEventEmitter = \
333
+ std::static_pointer_cast<RNMapsGoogleMapViewEventEmitter const>(_eventEmitter); \
334
+ facebook::react::RNMapsGoogleMapViewEventEmitter::eventName data = { \
335
+ .coordinate.latitude = [coordinateDict[@"latitude"] doubleValue], \
336
+ .coordinate.longitude = [coordinateDict[@"longitude"] doubleValue], \
337
+ .id = std::string([[dictionary valueForKey:@"id"] UTF8String]), \
338
+ }; \
339
+ mapViewEventEmitter->emitterFunction(data); \
340
+ }
341
+
342
+
343
+
344
+ #define HANDLE_MARKER_EVENT(eventName, emitterFunction, actionName) \
345
+ if (_eventEmitter) { \
346
+ NSDictionary* coordinateDict = dictionary[@"coordinate"]; \
347
+ facebook::react::RNMapsGoogleMapViewEventEmitter::eventName##Coordinate coordinate = { \
348
+ .latitude = [coordinateDict[@"latitude"] doubleValue], \
349
+ .longitude = [coordinateDict[@"longitude"] doubleValue], \
350
+ }; \
351
+ \
352
+ auto mapViewEventEmitter = \
353
+ std::static_pointer_cast<RNMapsGoogleMapViewEventEmitter const>(_eventEmitter); \
354
+ facebook::react::RNMapsGoogleMapViewEventEmitter::eventName data = { \
355
+ .action = std::string([@actionName UTF8String]), \
356
+ .id = std::string([[dictionary valueForKey:@"id"] UTF8String]), \
357
+ .coordinate = coordinate \
358
+ }; \
359
+ mapViewEventEmitter->emitterFunction(data); \
360
+ }
361
+
362
+ _view.onMarkerSelect = [self](NSDictionary* dictionary) {
363
+ HANDLE_MARKER_EVENT(OnMarkerSelect, onMarkerSelect, "marker-select");
364
+ };
365
+
366
+ _view.onMarkerDeselect = [self](NSDictionary* dictionary) {
367
+ HANDLE_MARKER_EVENT(OnMarkerDeselect, onMarkerDeselect, "marker-deselect");
368
+ };
369
+
370
+ _view.onMarkerPress = [self](NSDictionary* dictionary) {
371
+ HANDLE_MARKER_EVENT(OnMarkerPress, onMarkerPress, "marker-press");
372
+ };
373
+ }
374
+
375
+ - (instancetype)initWithFrame:(CGRect)frame
376
+ {
377
+ if (self = [super initWithFrame:frame]) {
378
+ static const auto defaultProps = std::make_shared<const RNMapsGoogleMapViewProps>();
379
+ _props = defaultProps;
380
+ _legacyMapManager = [[AIRGoogleMapManager alloc] init];
381
+ _pendingInsertsSubviews = [NSMutableDictionary new];
382
+ }
383
+
384
+ return self;
385
+ }
386
+
387
+
388
+ - (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index{
389
+ id<RCTComponent> paperView = [childComponentView getPaperViewFromChildComponentView];
390
+ if (paperView){
391
+ if(_view && [_view isReady]){
392
+ [_view insertReactSubview:paperView atIndex:index];
393
+ } else {
394
+ [_pendingInsertsSubviews setObject:paperView forKey:[NSNumber numberWithInteger:index]];
395
+ }
396
+ } else {
397
+ [_view insertReactSubview:childComponentView atIndex:index];
398
+ if ([childComponentView isKindOfClass:[RNMapsGooglePolygonView class]]){
399
+ RNMapsGooglePolygonView* polygon = (RNMapsGooglePolygonView *) childComponentView;
400
+ [_polygons addObject:childComponentView];
401
+ [polygon didInsertInMap:_view];
402
+ }
403
+ }
404
+ }
405
+
406
+ - (void) unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
407
+ {
408
+ id<RCTComponent> paperView = [childComponentView getPaperViewFromChildComponentView];
409
+ if (paperView){
410
+ if(_view && [_view isReady]){
411
+ [_view removeReactSubview:paperView];
412
+ } else {
413
+ [_pendingInsertsSubviews removeObjectForKey:[NSNumber numberWithInteger:index]];
414
+ }
415
+ } else {
416
+ [_view removeReactSubview:childComponentView];
417
+ if ([childComponentView isKindOfClass:[RNMapsGooglePolygonView class]]){
418
+ RNMapsGooglePolygonView* polygon = (RNMapsGooglePolygonView *) childComponentView;
419
+ [_polygons removeObject:childComponentView];
420
+ [polygon didRemoveFromMap];
421
+ }
422
+ }
423
+ }
424
+ - (void) prepareForRecycle
425
+ {
426
+ [super prepareForRecycle];
427
+ static const auto defaultProps = std::make_shared<const RNMapsGoogleMapViewProps>();
428
+ _props = defaultProps;
429
+ _legacyMapManager = [[AIRGoogleMapManager alloc] init];
430
+ _pendingInsertsSubviews = [NSMutableDictionary new];
431
+ [_view removeFromSuperview];
432
+ _view = nil;
433
+ }
434
+
435
+
436
+ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
437
+ {
438
+ const auto &oldViewProps = *std::static_pointer_cast<RNMapsGoogleMapViewProps const>(_props);
439
+ const auto &newViewProps = *std::static_pointer_cast<RNMapsGoogleMapViewProps const>(props);
440
+
441
+
442
+ if (oldViewProps.googleMapId != newViewProps.googleMapId) {
443
+ NSString* mapID = RCTNSStringFromString(newViewProps.googleMapId);
444
+ if (mapID && [mapID length]){
445
+ _legacyMapManager.googleMapId = mapID;
446
+ }
447
+ }
448
+ if (!newViewProps.zoomTapEnabled) {
449
+ _legacyMapManager.zoomTapEnabled = newViewProps.zoomTapEnabled;
450
+ } else {
451
+ _legacyMapManager.zoomTapEnabled = true;
452
+ }
453
+ if (oldViewProps.loadingBackgroundColor != newViewProps.loadingBackgroundColor){
454
+ _legacyMapManager.backgroundColor = RCTUIColorFromSharedColor(newViewProps.backgroundColor);
455
+ }
456
+
457
+ // bug with zoom / pitch / heading where value is not 0 even though
458
+ // nothing is passed from JS so we depend on lat / lng comparison for now
459
+ if (newViewProps.initialCamera.center.latitude != oldViewProps.initialCamera.center.latitude ||
460
+ newViewProps.initialCamera.center.longitude != oldViewProps.initialCamera.center.longitude ||
461
+ newViewProps.initialCamera.pitch != oldViewProps.initialCamera.pitch ||
462
+ newViewProps.initialCamera.zoom != oldViewProps.initialCamera.zoom
463
+ || newViewProps.initialCamera.heading != oldViewProps.initialCamera.heading) {
464
+ GMSCameraPosition* camera = [GMSCameraPosition cameraWithLatitude:newViewProps.initialCamera.center.latitude
465
+ longitude:newViewProps.initialCamera.center.longitude
466
+ zoom:newViewProps.initialCamera.zoom
467
+ bearing:newViewProps.initialCamera.heading
468
+ viewingAngle:newViewProps.initialCamera.pitch];
469
+ _legacyMapManager.camera = camera;
470
+ }
471
+
472
+
473
+
474
+ if (!_view){
475
+ [self prepareContentView];
476
+ }
477
+
478
+ #define REMAP_MAPVIEW_PROP(name) \
479
+ if (oldViewProps.name != newViewProps.name) { \
480
+ _view.name = newViewProps.name; \
481
+ }
482
+
483
+ #define REMAP_MAPVIEW_STRING_PROP(name) \
484
+ if (oldViewProps.name != newViewProps.name) { \
485
+ _view.name = RCTNSStringFromString(newViewProps.name); \
486
+ }
487
+
488
+ #define REMAP_MAPVIEW_POINT_PROP(name) \
489
+ if (newViewProps.name.x != oldViewProps.name.x || \
490
+ newViewProps.name.y != oldViewProps.name.y) { \
491
+ _view.name = CGPointMake(newViewProps.name.x, newViewProps.name.y); \
492
+ }
493
+
494
+ #define REMAP_MAPVIEW_REGION_PROP(name) \
495
+ if (newViewProps.name.latitude != oldViewProps.name.latitude || \
496
+ newViewProps.name.longitude != oldViewProps.name.longitude || \
497
+ newViewProps.name.latitudeDelta != oldViewProps.name.latitudeDelta ||\
498
+ newViewProps.name.longitudeDelta != oldViewProps.name.longitudeDelta) { \
499
+ MKCoordinateSpan span = MKCoordinateSpanMake(newViewProps.name.latitudeDelta, \
500
+ newViewProps.name.longitudeDelta); \
501
+ MKCoordinateRegion region = MKCoordinateRegionMake(CLLocationCoordinate2DMake( \
502
+ newViewProps.name.latitude, newViewProps.name.longitude), span); \
503
+ _view.name = region; \
504
+ }
505
+
506
+
507
+ #define REMAP_MAPVIEW_EDGEINSETS_PROP(name) \
508
+ if (newViewProps.name.top != oldViewProps.name.top || \
509
+ newViewProps.name.right != oldViewProps.name.right || \
510
+ newViewProps.name.bottom != oldViewProps.name.bottom || \
511
+ newViewProps.name.left != oldViewProps.name.left) { \
512
+ _view.name = UIEdgeInsetsMake(newViewProps.name.top, \
513
+ newViewProps.name.left, \
514
+ newViewProps.name.bottom, \
515
+ newViewProps.name.right); \
516
+ }
517
+
518
+
519
+ REMAP_MAPVIEW_PROP(pitchEnabled)
520
+ REMAP_MAPVIEW_PROP(zoomTapEnabled)
521
+ REMAP_MAPVIEW_PROP(scrollEnabled)
522
+
523
+
524
+ if (newViewProps.minZoom != oldViewProps.minZoom || newViewProps.maxZoom != oldViewProps.maxZoom){
525
+ [_view setMinZoom:newViewProps.minZoom maxZoom:newViewProps.maxZoom];
526
+ }
527
+
528
+ [_view setShowsCompass:newViewProps.showsCompass];
529
+ REMAP_MAPVIEW_PROP(showsTraffic)
530
+ REMAP_MAPVIEW_PROP(showsUserLocation)
531
+ REMAP_MAPVIEW_PROP(zoomEnabled)
532
+
533
+
534
+ REMAP_MAPVIEW_REGION_PROP(region)
535
+ REMAP_MAPVIEW_REGION_PROP(initialRegion)
536
+
537
+ if (newViewProps.camera.center.latitude != oldViewProps.camera.center.latitude ||
538
+ newViewProps.camera.center.longitude != oldViewProps.camera.center.longitude ||
539
+ newViewProps.camera.heading != oldViewProps.camera.heading ||
540
+ newViewProps.camera.pitch != oldViewProps.camera.pitch ||
541
+ newViewProps.camera.zoom != oldViewProps.camera.zoom) {
542
+ GMSCameraPosition* camera = [GMSCameraPosition cameraWithLatitude:newViewProps.camera.center.latitude
543
+ longitude:newViewProps.camera.center.longitude
544
+ zoom:newViewProps.camera.zoom
545
+ bearing:newViewProps.camera.heading
546
+ viewingAngle:newViewProps.camera.pitch];
547
+ _view.cameraProp = camera;
548
+ }
549
+
550
+
551
+ REMAP_MAPVIEW_EDGEINSETS_PROP(mapPadding)
552
+
553
+
554
+ if (oldViewProps.mapType != newViewProps.mapType){
555
+ switch (newViewProps.mapType) {
556
+ case RNMapsGoogleMapViewMapType::Standard:
557
+ _view.mapType = kGMSTypeNormal;
558
+ break;
559
+ case RNMapsGoogleMapViewMapType::Satellite:
560
+ _view.mapType = kGMSTypeSatellite;
561
+ break;
562
+ case RNMapsGoogleMapViewMapType::Terrain:
563
+ _view.mapType = kGMSTypeTerrain;
564
+ break;
565
+ case RNMapsGoogleMapViewMapType::Hybrid:
566
+ _view.mapType = kGMSTypeHybrid;
567
+ break;
568
+ default:
569
+ _view.mapType = kGMSTypeNormal;
570
+ break;
571
+ }
572
+ }
573
+
574
+ if (oldViewProps.userInterfaceStyle != newViewProps.userInterfaceStyle){
575
+ switch (newViewProps.userInterfaceStyle) {
576
+ case RNMapsGoogleMapViewUserInterfaceStyle::Light:
577
+ _view.overrideUserInterfaceStyle = UIUserInterfaceStyleLight;
578
+ break;
579
+ case RNMapsGoogleMapViewUserInterfaceStyle::Dark:
580
+ _view.overrideUserInterfaceStyle = UIUserInterfaceStyleDark;
581
+ break;
582
+ case RNMapsGoogleMapViewUserInterfaceStyle::System:
583
+ _view.overrideUserInterfaceStyle = UIUserInterfaceStyleUnspecified;
584
+ break;
585
+ }
586
+ }
587
+
588
+
589
+ [super updateProps:props oldProps:oldProps];
590
+ }
591
+
592
+ @end
593
+
594
+ Class<RCTComponentViewProtocol> RNMapsGoogleMapViewCls(void)
595
+ {
596
+ return RNMapsGoogleMapView.class;
597
+ }
598
+
599
+ #endif
@@ -0,0 +1,25 @@
1
+ //
2
+ // RNMapsMapViewManager.mm
3
+ // AirMaps
4
+ //
5
+ // Created by Salah Ghanim on 23.11.24.
6
+ // Copyright © 2024 react-native-maps. All rights reserved.
7
+ //
8
+ #ifdef HAVE_GOOGLE_MAPS
9
+
10
+ #import <React/RCTLog.h>
11
+ #import <React/RCTUIManager.h>
12
+ #import <React/RCTViewManager.h>
13
+
14
+ @interface RNMapsGoogleMapViewManager : RCTViewManager
15
+ @end
16
+
17
+ @implementation RNMapsGoogleMapViewManager
18
+
19
+ RCT_EXPORT_MODULE(RNMapsGoogleMapViewManager)
20
+
21
+
22
+
23
+ @end
24
+
25
+ #endif
@@ -0,0 +1,26 @@
1
+ //
2
+ // RNMapsGoogleMapView.h
3
+ //
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
+ #ifdef HAVE_GOOGLE_MAPS
10
+
11
+ #import <React/RCTViewComponentView.h>
12
+ #import <UIKit/UIKit.h>
13
+
14
+ @class AIRGoogleMap;
15
+ @class AIRGMSPolygon;
16
+
17
+ NS_ASSUME_NONNULL_BEGIN
18
+ @interface RNMapsGooglePolygonView : RCTViewComponentView
19
+ - (void) didInsertInMap:(AIRGoogleMap*) map;
20
+ - (void) didRemoveFromMap;
21
+ @end
22
+
23
+ NS_ASSUME_NONNULL_END
24
+
25
+ #endif
26
+ #endif