react-native-maps 1.21.0-alpha.1 → 1.21.0-alpha.11

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