react-native-maps 1.20.1 → 1.21.0-alpha.2

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.
@@ -0,0 +1,548 @@
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 "RNMapsMapView.h"
10
+ #import "AirMap.h"
11
+ #import "AIRMapMarker.h"
12
+ #import "AIRMapManager.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
+
18
+ #import "RCTFabricComponentsPlugins.h"
19
+ #import <React/RCTConversions.h>
20
+
21
+ using namespace facebook::react;
22
+
23
+ @interface RNMapsMapView () <RCTRNMapsMapViewViewProtocol>
24
+ @end
25
+
26
+ @implementation RNMapsMapView {
27
+ AIRMap *_view;
28
+ AIRMapManager* _legacyMapManager;
29
+ }
30
+
31
+
32
+ - (AIRMap *) mapView {
33
+ return _view;
34
+ }
35
+
36
+ #pragma mark - JS Commands
37
+ - (void)animateToRegion:(NSString *)regionJSON duration:(NSInteger)duration{
38
+ NSDictionary* regionDic = [RCTConvert dictonaryFromString:regionJSON];
39
+ [AIRMap animateWithDuration:duration/1000 animations:^{
40
+ [self->_view setRegion:[RCTConvert MKCoordinateRegion:regionDic] animated:YES];
41
+ }];
42
+ }
43
+ - (void)setCamera:(NSString *)cameraJSON{
44
+ NSDictionary* cameraDic = [RCTConvert dictonaryFromString:cameraJSON];
45
+ MKMapCamera *camera = [RCTConvert MKMapCameraWithDefaults:cameraDic existingCamera:[_view camera]];
46
+ [_view setCamera:camera];
47
+ }
48
+
49
+ - (void)animateCamera:(NSString *)cameraJSON duration:(NSInteger)duration{
50
+ NSDictionary* cameraDic = [RCTConvert dictonaryFromString:cameraJSON];
51
+ MKMapCamera *camera = [RCTConvert MKMapCameraWithDefaults:cameraDic existingCamera:[_view camera]];
52
+
53
+ // don't emit region change events when we are setting the camera
54
+ BOOL originalIgnore = _view.ignoreRegionChanges;
55
+ _view.ignoreRegionChanges = YES;
56
+ [AIRMap animateWithDuration:duration/1000 animations:^{
57
+ [self->_view setCamera:camera animated:YES];
58
+ } completion:^(BOOL finished){
59
+ self->_view.ignoreRegionChanges = originalIgnore;
60
+ }];
61
+
62
+ }
63
+
64
+ - (void)fitToElements:(NSString *)edgePaddingJSON animated:(BOOL)animated {
65
+ [_view showAnnotations:_view.annotations animated:animated];
66
+ }
67
+
68
+ - (void)fitToSuppliedMarkers:(NSString *)markersJSON edgePaddingJSON:(NSString *)edgePaddingJSON animated:(BOOL)animated {
69
+ NSArray* markers = [RCTConvert arrayFromString:markersJSON];
70
+ NSPredicate *filterMarkers = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings) {
71
+ AIRMapMarker *marker = (AIRMapMarker *)evaluatedObject;
72
+ return [marker isKindOfClass:[AIRMapMarker class]] && [markers containsObject:marker.identifier];
73
+ }];
74
+ NSArray *filteredMarkers = [_view.annotations filteredArrayUsingPredicate:filterMarkers];
75
+ [_view showAnnotations:filteredMarkers animated:animated];
76
+
77
+ }
78
+ - (void)fitToCoordinates:(NSString *)coordinatesJSON edgePaddingJSON:(NSString *)edgePaddingJSON animated:(BOOL)animated {
79
+
80
+ }
81
+
82
+ #pragma mark - Native commands
83
+
84
+ - (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args
85
+ {
86
+ RCTRNMapsMapViewHandleCommand(self, commandName, args);
87
+ }
88
+
89
+
90
+ + (ComponentDescriptorProvider)componentDescriptorProvider
91
+ {
92
+ return concreteComponentDescriptorProvider<RNMapsMapViewComponentDescriptor>();
93
+ }
94
+
95
+
96
+ - (instancetype)initWithFrame:(CGRect)frame
97
+ {
98
+ if (self = [super initWithFrame:frame]) {
99
+ static const auto defaultProps = std::make_shared<const RNMapsMapViewProps>();
100
+ _props = defaultProps;
101
+ _legacyMapManager = [[AIRMapManager alloc] init];
102
+ _view = (AIRMap *)[_legacyMapManager view];
103
+
104
+ self.contentView = _view;
105
+
106
+ _view.onPress = [self](NSDictionary* dictionary) {
107
+ if (_eventEmitter) {
108
+ // Extract values from the NSDictionary
109
+ NSDictionary* coordinateDict = dictionary[@"coordinate"];
110
+ NSDictionary* positionDict = dictionary[@"position"];
111
+
112
+ // Populate the OnMapPressCoordinate struct
113
+ facebook::react::RNMapsMapViewEventEmitter::OnPressCoordinate coordinate = {
114
+ .latitude = [coordinateDict[@"latitude"] doubleValue],
115
+ .longitude = [coordinateDict[@"longitude"] doubleValue],
116
+ };
117
+
118
+ // Populate the OnMapPressPosition struct
119
+ facebook::react::RNMapsMapViewEventEmitter::OnPressPosition position = {
120
+ .x = [positionDict[@"x"] doubleValue],
121
+ .y = [positionDict[@"y"] doubleValue],
122
+ };
123
+
124
+ auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
125
+ facebook::react::RNMapsMapViewEventEmitter::OnPress data = {
126
+ .action = std::string([@"press" UTF8String]),
127
+ .position = position,
128
+ .coordinate = coordinate
129
+ };
130
+ mapViewEventEmitter->onPress(data);
131
+ }
132
+ };
133
+
134
+
135
+ _view.onMapReady = [self](NSDictionary* dictionary) {
136
+ if (_eventEmitter) {
137
+
138
+ auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
139
+ facebook::react::RNMapsMapViewEventEmitter::OnMapReady data = {};
140
+ mapViewEventEmitter->onMapReady(data);
141
+ }
142
+ };
143
+ _view.onChange = [self](NSDictionary* dictionary) {
144
+ if (_eventEmitter) {
145
+
146
+ NSDictionary* regionDict = dictionary[@"region"];
147
+ auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
148
+ facebook::react::RNMapsMapViewEventEmitter::OnRegionChange data = {
149
+ .region.latitude = [regionDict[@"latitude"] doubleValue],
150
+ .region.longitude = [regionDict[@"longitude"] doubleValue],
151
+ .region.latitudeDelta = [regionDict[@"latitudeDelta"] doubleValue],
152
+ .region.longitudeDelta = [regionDict[@"longitudeDelta"] doubleValue],
153
+ .continuous = [dictionary[@"continuous"] boolValue],
154
+ };
155
+ mapViewEventEmitter->onRegionChange(data);
156
+ }
157
+ };
158
+ _view.onDoublePress = [self](NSDictionary* dictionary) {
159
+ if (_eventEmitter) {
160
+
161
+ NSDictionary* coordinateDict = dictionary[@"coordinate"];
162
+ NSDictionary* positionDict = dictionary[@"position"];
163
+
164
+ // Populate the OnMapPressCoordinate struct
165
+ facebook::react::RNMapsMapViewEventEmitter::OnDoublePressCoordinate coordinate = {
166
+ .latitude = [coordinateDict[@"latitude"] doubleValue],
167
+ .longitude = [coordinateDict[@"longitude"] doubleValue],
168
+ };
169
+
170
+ // Populate the OnMapDouplePressPosition struct
171
+ facebook::react::RNMapsMapViewEventEmitter::OnDoublePressPosition position = {
172
+ .x = [positionDict[@"x"] doubleValue],
173
+ .y = [positionDict[@"y"] doubleValue],
174
+ };
175
+
176
+
177
+ auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
178
+ facebook::react::RNMapsMapViewEventEmitter::OnDoublePress data = {
179
+ .position = position,
180
+ .coordinate = coordinate
181
+ };
182
+ mapViewEventEmitter->onDoublePress(data);
183
+ }
184
+ };
185
+
186
+ _view.onPanDrag = [self](NSDictionary* dictionary) {
187
+ if (_eventEmitter) {
188
+
189
+ NSDictionary* coordinateDict = dictionary[@"coordinate"];
190
+ NSDictionary* positionDict = dictionary[@"position"];
191
+
192
+ // Populate the OnMapPressCoordinate struct
193
+ facebook::react::RNMapsMapViewEventEmitter::OnPanDragCoordinate coordinate = {
194
+ .latitude = [coordinateDict[@"latitude"] doubleValue],
195
+ .longitude = [coordinateDict[@"longitude"] doubleValue],
196
+ };
197
+
198
+ // Populate the OnMapDouplePressPosition struct
199
+ facebook::react::RNMapsMapViewEventEmitter::OnPanDragPosition position = {
200
+ .x = [positionDict[@"x"] doubleValue],
201
+ .y = [positionDict[@"y"] doubleValue],
202
+ };
203
+
204
+ auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
205
+ facebook::react::RNMapsMapViewEventEmitter::OnPanDrag data = {
206
+ .position = position,
207
+ .coordinate = coordinate,
208
+ };
209
+ mapViewEventEmitter->onPanDrag(data);
210
+ }
211
+ };
212
+
213
+ _view.onUserLocationChange = [self](NSDictionary* dictionary) {
214
+ if (_eventEmitter) {
215
+
216
+ NSDictionary* coordinateDict = dictionary[@"coordinate"];
217
+ NSDictionary* errorDict = dictionary[@"error"];
218
+
219
+
220
+ // Populate the OnMapPressCoordinate struct
221
+ facebook::react::RNMapsMapViewEventEmitter::OnUserLocationChangeCoordinate coordinate = {
222
+ .latitude = [coordinateDict[@"latitude"] doubleValue],
223
+ .longitude = [coordinateDict[@"longitude"] doubleValue],
224
+ };
225
+ facebook::react::RNMapsMapViewEventEmitter::OnUserLocationChangeError error = {
226
+ .message = std::string([errorDict[@"message"] UTF8String]),
227
+ };
228
+
229
+
230
+ auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
231
+ facebook::react::RNMapsMapViewEventEmitter::OnUserLocationChange data = {
232
+ .coordinate = coordinate,
233
+ .error = error,
234
+ };
235
+ mapViewEventEmitter->onUserLocationChange(data);
236
+ }
237
+ };
238
+
239
+ _view.onCalloutPress = [self](NSDictionary* dictionary) {
240
+ if (_eventEmitter) {
241
+
242
+ NSDictionary* coordinateDict = dictionary[@"coordinate"];
243
+ NSDictionary* positionDict = dictionary[@"position"];
244
+
245
+ // Populate the OnCalloutPressPoint struct
246
+ facebook::react::RNMapsMapViewEventEmitter::OnCalloutPressPoint point = {
247
+ .x = [coordinateDict[@"x"] doubleValue],
248
+ .y = [coordinateDict[@"y"] doubleValue],
249
+ };
250
+
251
+
252
+ facebook::react::RNMapsMapViewEventEmitter::OnCalloutPressFrame frame = {
253
+ .x = [positionDict[@"x"] doubleValue],
254
+ .y = [positionDict[@"y"] doubleValue],
255
+ .width = [positionDict[@"width"] doubleValue],
256
+ .height = [positionDict[@"height"] doubleValue],
257
+ };
258
+ /*
259
+ std::string action;
260
+ OnCalloutPressFrame frame;
261
+ std::string id;
262
+ OnCalloutPressPoint point;
263
+ OnCalloutPressCoordinate coordinate;
264
+ OnCalloutPressPosition position;
265
+ id event = @{
266
+ @"action": calloutSubview ? @"callout-inside-press" : @"callout-press",
267
+ @"id": marker.identifier ?: @"unknown",
268
+ @"point": @{
269
+ @"x": @(touchPointReal.x),
270
+ @"y": @(touchPointReal.y),
271
+ },
272
+ @"frame": @{
273
+ @"x": @(bubbleFrame.origin.x),
274
+ @"y": @(bubbleFrame.origin.y),
275
+ @"width": @(bubbleFrame.size.width),
276
+ @"height": @(bubbleFrame.size.height),
277
+ }
278
+ };
279
+ */
280
+
281
+ auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
282
+ facebook::react::RNMapsMapViewEventEmitter::OnCalloutPress data = {
283
+ .action = std::string([dictionary[@"action"] UTF8String]),
284
+ .id = std::string([dictionary[@"id"] UTF8String]),
285
+ .point = point,
286
+ .frame = frame,
287
+ };
288
+ mapViewEventEmitter->onCalloutPress(data);
289
+ }
290
+ };
291
+
292
+
293
+ _view.onRegionChangeStart = [self](NSDictionary* dictionary) {
294
+ if (_eventEmitter) {
295
+
296
+ NSDictionary* regionDict = dictionary[@"region"];
297
+ auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
298
+ facebook::react::RNMapsMapViewEventEmitter::OnRegionChangeStart data = {
299
+ .region.latitude = [regionDict[@"latitude"] doubleValue],
300
+ .region.longitude = [regionDict[@"longitude"] doubleValue],
301
+ .region.latitudeDelta = [regionDict[@"latitudeDelta"] doubleValue],
302
+ .region.longitudeDelta = [regionDict[@"longitudeDelta"] doubleValue],
303
+ .continuous = [dictionary[@"continuous"] boolValue],
304
+ };
305
+ mapViewEventEmitter->onRegionChangeStart(data);
306
+ }
307
+ };
308
+
309
+
310
+ #define HANDLE_MARKER_DRAG_EVENT(eventName, emitterFunction) \
311
+ if (_eventEmitter) { \
312
+ NSDictionary* coordinateDict = dictionary[@"coordinate"]; \
313
+ auto mapViewEventEmitter = \
314
+ std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter); \
315
+ facebook::react::RNMapsMapViewEventEmitter::eventName data = { \
316
+ .coordinate.latitude = [coordinateDict[@"latitude"] doubleValue], \
317
+ .coordinate.longitude = [coordinateDict[@"longitude"] doubleValue], \
318
+ .id = std::string([[dictionary valueForKey:@"id"] UTF8String]), \
319
+ }; \
320
+ mapViewEventEmitter->emitterFunction(data); \
321
+ }
322
+
323
+
324
+
325
+ #define HANDLE_MARKER_EVENT(eventName, emitterFunction, actionName) \
326
+ if (_eventEmitter) { \
327
+ NSDictionary* coordinateDict = dictionary[@"coordinate"]; \
328
+ facebook::react::RNMapsMapViewEventEmitter::eventName##Coordinate coordinate = { \
329
+ .latitude = [coordinateDict[@"latitude"] doubleValue], \
330
+ .longitude = [coordinateDict[@"longitude"] doubleValue], \
331
+ }; \
332
+ \
333
+ auto mapViewEventEmitter = \
334
+ std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter); \
335
+ facebook::react::RNMapsMapViewEventEmitter::eventName data = { \
336
+ .action = std::string([@actionName UTF8String]), \
337
+ .id = std::string([[dictionary valueForKey:@"id"] UTF8String]), \
338
+ .coordinate = coordinate \
339
+ }; \
340
+ mapViewEventEmitter->emitterFunction(data); \
341
+ }
342
+
343
+ _view.onMarkerDrag = [self](NSDictionary* dictionary) {
344
+ HANDLE_MARKER_DRAG_EVENT(OnMarkerDrag, onMarkerDrag);
345
+ };
346
+
347
+ _view.onMarkerDragStart = [self](NSDictionary* dictionary) {
348
+ HANDLE_MARKER_DRAG_EVENT(OnMarkerDragStart, onMarkerDragStart);
349
+ };
350
+
351
+ _view.onMarkerDragEnd = [self](NSDictionary* dictionary) {
352
+ HANDLE_MARKER_DRAG_EVENT(OnMarkerDragEnd, onMarkerDragEnd);
353
+ };
354
+
355
+ _view.onMarkerSelect = [self](NSDictionary* dictionary) {
356
+ HANDLE_MARKER_EVENT(OnMarkerSelect, onMarkerSelect, "marker-select");
357
+ };
358
+
359
+ _view.onMarkerDeselect = [self](NSDictionary* dictionary) {
360
+ HANDLE_MARKER_EVENT(OnMarkerDeselect, onMarkerDeselect, "marker-deselect");
361
+ };
362
+
363
+ _view.onMarkerPress = [self](NSDictionary* dictionary) {
364
+ HANDLE_MARKER_EVENT(OnMarkerPress, onMarkerPress, "marker-press");
365
+ };
366
+
367
+
368
+
369
+ }
370
+
371
+ return self;
372
+ }
373
+
374
+ - (id)getPaperViewFromChildComponentView:(UIView *)childComponentView {
375
+ // Check if the childComponentView responds to the "adapter" selector
376
+ if ([childComponentView respondsToSelector:@selector(paperView)]) {
377
+ // Safely return the paperView
378
+ return [childComponentView valueForKey:@"paperView"];
379
+ }
380
+ // Return nil if paperView is not accessible
381
+ return nil;
382
+ }
383
+
384
+ - (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index{
385
+ id<RCTComponent> paperView = [self getPaperViewFromChildComponentView:childComponentView];
386
+ if (paperView){
387
+ [_view insertReactSubview:paperView atIndex:index];
388
+ }
389
+ }
390
+ - (void) unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
391
+ {
392
+ id<RCTComponent> paperView = [self getPaperViewFromChildComponentView:childComponentView];
393
+ if (paperView){
394
+ [_view removeReactSubview:paperView];
395
+ }
396
+ }
397
+
398
+ MKMapType mapRNTypeToMKMapType(RNMapsMapViewMapType rnMapType) {
399
+ switch (rnMapType) {
400
+ case RNMapsMapViewMapType::Standard: return MKMapTypeStandard;
401
+ case RNMapsMapViewMapType::Satellite: return MKMapTypeSatellite;
402
+ case RNMapsMapViewMapType::Hybrid: return MKMapTypeHybrid;
403
+ case RNMapsMapViewMapType::MutedStandard: return MKMapTypeMutedStandard;
404
+ case RNMapsMapViewMapType::SatelliteFlyover: return MKMapTypeSatelliteFlyover;
405
+ case RNMapsMapViewMapType::HybridFlyover: return MKMapTypeHybridFlyover;
406
+ default: return MKMapTypeStandard; // Default case
407
+ }
408
+ }
409
+
410
+
411
+ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
412
+ {
413
+ const auto &oldViewProps = *std::static_pointer_cast<RNMapsMapViewProps const>(_props);
414
+ const auto &newViewProps = *std::static_pointer_cast<RNMapsMapViewProps const>(props);
415
+
416
+ #define REMAP_MAPVIEW_PROP(name) \
417
+ if (oldViewProps.name != newViewProps.name) { \
418
+ _view.name = newViewProps.name; \
419
+ }
420
+
421
+ #define REMAP_MAPVIEW_STRING_PROP(name) \
422
+ if (oldViewProps.name != newViewProps.name) { \
423
+ _view.name = RCTNSStringFromString(newViewProps.name); \
424
+ }
425
+
426
+ #define REMAP_MAPVIEW_COLOR_PROP(name) \
427
+ if (oldViewProps.name != newViewProps.name) { \
428
+ _view.name = RCTUIColorFromSharedColor(newViewProps.name); \
429
+ }
430
+
431
+ #define REMAP_MAPVIEW_POINT_PROP(name) \
432
+ if (newViewProps.name.x != oldViewProps.name.x || \
433
+ newViewProps.name.y != oldViewProps.name.y) { \
434
+ _view.name = CGPointMake(newViewProps.name.x, newViewProps.name.y); \
435
+ }
436
+
437
+ #define REMAP_MAPVIEW_REGION_PROP(name) \
438
+ if (newViewProps.name.latitude != oldViewProps.name.latitude || \
439
+ newViewProps.name.longitude != oldViewProps.name.longitude || \
440
+ newViewProps.name.latitudeDelta != oldViewProps.name.latitudeDelta ||\
441
+ newViewProps.name.longitudeDelta != oldViewProps.name.longitudeDelta) { \
442
+ MKCoordinateSpan span = MKCoordinateSpanMake(newViewProps.name.latitudeDelta, \
443
+ newViewProps.name.longitudeDelta); \
444
+ MKCoordinateRegion region = MKCoordinateRegionMake(CLLocationCoordinate2DMake( \
445
+ newViewProps.name.latitude, newViewProps.name.longitude), span); \
446
+ _view.name = region; \
447
+ }
448
+
449
+ #define REMAP_MAPVIEW_CAMERA_PROP(name) \
450
+ if (newViewProps.name.center.latitude != oldViewProps.name.center.latitude || \
451
+ newViewProps.name.center.longitude != oldViewProps.name.center.longitude || \
452
+ newViewProps.name.heading != oldViewProps.name.heading || \
453
+ newViewProps.name.pitch != oldViewProps.name.pitch) { \
454
+ CLLocationCoordinate2D center = CLLocationCoordinate2DMake( \
455
+ newViewProps.name.center.latitude, \
456
+ newViewProps.name.center.longitude); \
457
+ MKMapCamera* camera = [[MKMapCamera alloc] init]; \
458
+ camera.centerCoordinate = center; \
459
+ camera.heading = newViewProps.name.heading; \
460
+ camera.pitch = newViewProps.name.pitch; \
461
+ _view.name = camera; \
462
+ }
463
+
464
+ #define REMAP_MAPVIEW_EDGEINSETS_PROP(name) \
465
+ if (newViewProps.name.top != oldViewProps.name.top || \
466
+ newViewProps.name.right != oldViewProps.name.right || \
467
+ newViewProps.name.bottom != oldViewProps.name.bottom || \
468
+ newViewProps.name.left != oldViewProps.name.left) { \
469
+ _view.name = UIEdgeInsetsMake(newViewProps.name.top, \
470
+ newViewProps.name.left, \
471
+ newViewProps.name.bottom, \
472
+ newViewProps.name.right); \
473
+ }
474
+
475
+ #define REMAP_MAPVIEW_MAPTYPE(rnMapType) MKMapType##rnMapType
476
+
477
+
478
+ REMAP_MAPVIEW_PROP(cacheEnabled)
479
+
480
+ REMAP_MAPVIEW_PROP(followsUserLocation)
481
+ REMAP_MAPVIEW_PROP(loadingEnabled)
482
+ REMAP_MAPVIEW_PROP(scrollEnabled)
483
+
484
+ REMAP_MAPVIEW_PROP(maxDelta)
485
+ REMAP_MAPVIEW_PROP(maxZoomLevel)
486
+ REMAP_MAPVIEW_PROP(minDelta)
487
+ REMAP_MAPVIEW_PROP(minZoomLevel)
488
+
489
+ REMAP_MAPVIEW_PROP(showsCompass)
490
+ REMAP_MAPVIEW_PROP(showsScale)
491
+ REMAP_MAPVIEW_PROP(showsTraffic)
492
+ REMAP_MAPVIEW_PROP(showsUserLocation)
493
+ REMAP_MAPVIEW_PROP(userLocationCalloutEnabled)
494
+ REMAP_MAPVIEW_PROP(zoomEnabled)
495
+
496
+ REMAP_MAPVIEW_POINT_PROP(compassOffset)
497
+
498
+ REMAP_MAPVIEW_REGION_PROP(region)
499
+ REMAP_MAPVIEW_REGION_PROP(initialRegion)
500
+
501
+ REMAP_MAPVIEW_CAMERA_PROP(initialCamera)
502
+ REMAP_MAPVIEW_CAMERA_PROP(camera)
503
+
504
+ REMAP_MAPVIEW_EDGEINSETS_PROP(legalLabelInsets)
505
+ REMAP_MAPVIEW_EDGEINSETS_PROP(mapPadding)
506
+
507
+ REMAP_MAPVIEW_COLOR_PROP(loadingIndicatorColor)
508
+ REMAP_MAPVIEW_COLOR_PROP(loadingIndicatorColor)
509
+ REMAP_MAPVIEW_COLOR_PROP(tintColor)
510
+
511
+ // userLocationAnnotationTitle
512
+ REMAP_MAPVIEW_STRING_PROP(userLocationAnnotationTitle)
513
+
514
+ if (oldViewProps.mapType != newViewProps.mapType){
515
+ _view.mapType = mapRNTypeToMKMapType(newViewProps.mapType);
516
+ }
517
+ if (oldViewProps.userInterfaceStyle != newViewProps.userInterfaceStyle){
518
+ switch (newViewProps.userInterfaceStyle) {
519
+ case RNMapsMapViewUserInterfaceStyle::Light:
520
+ _view.overrideUserInterfaceStyle = UIUserInterfaceStyleLight;
521
+ break;
522
+ case RNMapsMapViewUserInterfaceStyle::Dark:
523
+ _view.overrideUserInterfaceStyle = UIUserInterfaceStyleDark;
524
+ break;
525
+ case RNMapsMapViewUserInterfaceStyle::System:
526
+ _view.overrideUserInterfaceStyle = UIUserInterfaceStyleUnspecified;
527
+ break;
528
+ }
529
+ }
530
+
531
+ if (oldViewProps.cameraZoomRange.minCenterCoordinateDistance != newViewProps.cameraZoomRange.minCenterCoordinateDistance ||
532
+ oldViewProps.cameraZoomRange.maxCenterCoordinateDistance != newViewProps.cameraZoomRange.maxCenterCoordinateDistance ||
533
+ oldViewProps.cameraZoomRange.animated != newViewProps.cameraZoomRange.animated) {
534
+
535
+ MKMapCameraZoomRange* zoomRange = [[MKMapCameraZoomRange alloc] initWithMinCenterCoordinateDistance:newViewProps.cameraZoomRange.minCenterCoordinateDistance maxCenterCoordinateDistance:newViewProps.cameraZoomRange.maxCenterCoordinateDistance];
536
+ [_view setCameraZoomRange:zoomRange animated:newViewProps.cameraZoomRange.animated];
537
+ }
538
+
539
+
540
+ [super updateProps:props oldProps:oldProps];
541
+ }
542
+
543
+ @end
544
+
545
+ Class<RCTComponentViewProtocol> RNMapsMapViewCls(void)
546
+ {
547
+ return RNMapsMapView.class;
548
+ }
@@ -0,0 +1,24 @@
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 RNMapsMapViewManager : RCTViewManager
14
+ @end
15
+
16
+ @implementation RNMapsMapViewManager
17
+
18
+ RCT_EXPORT_MODULE(RNMapsMapViewManager)
19
+
20
+
21
+
22
+
23
+
24
+ @end
@@ -26,6 +26,8 @@
26
26
  4C99C9DE2226CF2800A8693E /* AIRWeakTimerReference.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C99C9DD2226CF2800A8693E /* AIRWeakTimerReference.m */; };
27
27
  4C99C9E12226D8C400A8693E /* AIRWeakMapReference.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C99C9E02226D8C400A8693E /* AIRWeakMapReference.m */; };
28
28
  4E0CFBDE2B388F2B0017E126 /* RCTComponentData+Maps.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E0CFBDD2B388F2B0017E126 /* RCTComponentData+Maps.m */; };
29
+ 4E430F272CF20153006E4F41 /* RNMapsMarkerManager.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4E430F262CF20153006E4F41 /* RNMapsMarkerManager.mm */; };
30
+ 4E430F2A2CF20305006E4F41 /* RNMapsMarker.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4E430F292CF20305006E4F41 /* RNMapsMarker.mm */; };
29
31
  53D31636202E723B00B55447 /* AIRMapOverlayManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 53D31635202E723B00B55447 /* AIRMapOverlayManager.m */; };
30
32
  53D3163A202E72FC00B55447 /* AIRMapOverlay.m in Sources */ = {isa = PBXBuildFile; fileRef = 53D31639202E72FC00B55447 /* AIRMapOverlay.m */; };
31
33
  53D3163D202E734F00B55447 /* AIRMapOverlayRenderer.m in Sources */ = {isa = PBXBuildFile; fileRef = 53D3163C202E734F00B55447 /* AIRMapOverlayRenderer.m */; };
@@ -117,6 +119,9 @@
117
119
  4E0A36152BFB4E76009FCCE4 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
118
120
  4E0CFBDC2B388F2B0017E126 /* RCTComponentData+Maps.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "RCTComponentData+Maps.h"; sourceTree = "<group>"; };
119
121
  4E0CFBDD2B388F2B0017E126 /* RCTComponentData+Maps.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "RCTComponentData+Maps.m"; sourceTree = "<group>"; };
122
+ 4E430F262CF20153006E4F41 /* RNMapsMarkerManager.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = RNMapsMarkerManager.mm; sourceTree = "<group>"; };
123
+ 4E430F282CF20305006E4F41 /* RNMapsMarker.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNMapsMarker.h; sourceTree = "<group>"; };
124
+ 4E430F292CF20305006E4F41 /* RNMapsMarker.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = RNMapsMarker.mm; sourceTree = "<group>"; };
120
125
  53D31635202E723B00B55447 /* AIRMapOverlayManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AIRMapOverlayManager.m; sourceTree = "<group>"; };
121
126
  53D31637202E725E00B55447 /* AIRMapOverlayManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AIRMapOverlayManager.h; sourceTree = "<group>"; };
122
127
  53D31638202E72D500B55447 /* AIRMapOverlay.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AIRMapOverlay.h; sourceTree = "<group>"; };
@@ -285,6 +290,9 @@
285
290
  4C99C9DD2226CF2800A8693E /* AIRWeakTimerReference.m */,
286
291
  4C99C9DF2226D8C400A8693E /* AIRWeakMapReference.h */,
287
292
  4C99C9E02226D8C400A8693E /* AIRWeakMapReference.m */,
293
+ 4E430F262CF20153006E4F41 /* RNMapsMarkerManager.mm */,
294
+ 4E430F282CF20305006E4F41 /* RNMapsMarker.h */,
295
+ 4E430F292CF20305006E4F41 /* RNMapsMarker.mm */,
288
296
  );
289
297
  path = AirMaps;
290
298
  sourceTree = "<group>";
@@ -417,6 +425,7 @@
417
425
  9B9498CE2017EFB800158761 /* AIRGMSMarker.m in Sources */,
418
426
  9B9498D72017EFB800158761 /* AIRGoogleMapManager.m in Sources */,
419
427
  19DABC7F1E7C9D3C00F41150 /* RCTConvert+AirMap.m in Sources */,
428
+ 4E430F272CF20153006E4F41 /* RNMapsMarkerManager.mm in Sources */,
420
429
  A8494E2E218891180092506D /* AIRGoogleMapWMSTileManager.m in Sources */,
421
430
  8B19A3C82257BBDF00BB8735 /* AIRMapCalloutSubview.m in Sources */,
422
431
  1125B2E51C4AD3DA007D0023 /* AIRMapPolyline.m in Sources */,
@@ -449,6 +458,7 @@
449
458
  DA6C26381C9E2AFE0035349F /* AIRMapUrlTile.m in Sources */,
450
459
  628F81231FD16EFA0058313A /* AIRMapLocalTileManager.m in Sources */,
451
460
  9B9498D22017EFB800158761 /* AIRGoogleMapMarkerManager.m in Sources */,
461
+ 4E430F2A2CF20305006E4F41 /* RNMapsMarker.mm in Sources */,
452
462
  9B9498CC2017EFB800158761 /* AIRGMSPolygon.m in Sources */,
453
463
  1125B2DE1C4AD3DA007D0023 /* AIRMapCircleManager.m in Sources */,
454
464
  1125B2DC1C4AD3DA007D0023 /* AIRMapCalloutManager.m in Sources */,
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ import type { MapBoundaries } from './specs/NativeAirMapsModule';
3
+ import type { MapFabricNativeProps, Camera, Point } from './specs/NativeComponentMapView';
4
+ import { LatLng, Region } from './sharedTypes';
5
+ import { Address, EdgePadding, SnapshotOptions } from './MapView.types';
6
+ export interface FabricMapHandle {
7
+ getCamera: () => Promise<Camera>;
8
+ setCamera: (camera: Partial<Camera>) => void;
9
+ animateToRegion: (region: Region, duration: number) => void;
10
+ animateCamera: (camera: Partial<Camera>, duration: number) => void;
11
+ getMarkersFrames: (onlyVisible: boolean) => Promise<unknown>;
12
+ fitToElements: (edgePadding: EdgePadding, animated: boolean) => void;
13
+ fitToSuppliedMarkers: (markers: string[], edgePadding: EdgePadding, animated: boolean) => void;
14
+ fitToCoordinates: (coordinates: LatLng[], edgePadding: EdgePadding, animated: boolean) => void;
15
+ getMapBoundaries: () => Promise<MapBoundaries>;
16
+ takeSnapshot: (config: SnapshotOptions) => Promise<string>;
17
+ getAddressFromCoordinates: (coordinate: LatLng) => Promise<Address>;
18
+ getPointForCoordinate: (coordinate: LatLng) => Promise<Point>;
19
+ getCoordinateForPoint: (point: Point) => Promise<LatLng>;
20
+ }
21
+ export declare const FabricMap: React.ForwardRefExoticComponent<MapFabricNativeProps & React.RefAttributes<FabricMapHandle>>;
22
+ export default FabricMap;