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

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 (50) hide show
  1. package/README.md +13 -6
  2. package/android/build.gradle +19 -4
  3. package/android/src/main/java/com/rnmaps/fabric/NativeAirMapsModule.java +51 -0
  4. package/android/src/main/java/com/rnmaps/maps/MapAirModulePackage.java +46 -0
  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 +581 -0
  24. package/ios/AirGoogleMaps/RNMapsGoogleMapViewManager.mm +25 -0
  25. package/ios/AirMaps/AIRMap.h +8 -5
  26. package/ios/AirMaps/AIRMap.m +180 -27
  27. package/ios/AirMaps/AIRMapManager.m +24 -39
  28. package/ios/AirMaps/AIRMapMarker.m +11 -3
  29. package/ios/AirMaps/RCTConvert+AirMap.h +6 -1
  30. package/ios/AirMaps/RCTConvert+AirMap.m +18 -0
  31. package/ios/AirMaps/RNMapsAirModule.h +16 -0
  32. package/ios/AirMaps/RNMapsAirModule.mm +149 -0
  33. package/ios/AirMaps/RNMapsMapView.h +24 -0
  34. package/ios/AirMaps/RNMapsMapView.mm +535 -0
  35. package/ios/AirMaps/RNMapsMapViewManager.mm +24 -0
  36. package/ios/AirMaps.xcodeproj/project.pbxproj +10 -0
  37. package/lib/MapOverlay.d.ts +1 -1
  38. package/lib/MapView.d.ts +8 -4
  39. package/lib/MapView.js +148 -73
  40. package/lib/createFabricMap.d.ts +23 -0
  41. package/lib/createFabricMap.js +175 -0
  42. package/lib/specs/NativeAirMapsModule.d.ts +31 -0
  43. package/lib/specs/NativeAirMapsModule.js +4 -0
  44. package/lib/specs/NativeComponentGoogleMapView.d.ts +713 -0
  45. package/lib/specs/NativeComponentGoogleMapView.js +21 -0
  46. package/lib/specs/NativeComponentMapView.d.ts +855 -0
  47. package/lib/specs/NativeComponentMapView.js +21 -0
  48. package/package.json +14 -7
  49. package/react-native-maps.podspec +3 -1
  50. package/react-native-google-maps.podspec +0 -25
@@ -0,0 +1,535 @@
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
+ - (id<RNMapsAirModuleDelegate>) 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
+ NSArray* coordinatesArr = [RCTConvert arrayFromString:coordinatesJSON];
80
+ NSMutableArray<AIRMapCoordinate*>* mutableArray = [NSMutableArray new];
81
+ for (id json : coordinatesArr){
82
+ [mutableArray addObject:[RCTConvert AIRMapCoordinate:json]];
83
+ }
84
+
85
+ NSDictionary* edgePadding = [RCTConvert dictonaryFromString:edgePaddingJSON];
86
+
87
+ UIEdgeInsets edgeInsets = [RCTConvert UIEdgeInsets:edgePadding];
88
+ [_view fitToCoordinates:mutableArray edgePadding:edgeInsets animated:animated];
89
+
90
+ }
91
+
92
+ #pragma mark - Native commands
93
+
94
+ - (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args
95
+ {
96
+ RCTRNMapsMapViewHandleCommand(self, commandName, args);
97
+ }
98
+
99
+
100
+ + (ComponentDescriptorProvider)componentDescriptorProvider
101
+ {
102
+ return concreteComponentDescriptorProvider<RNMapsMapViewComponentDescriptor>();
103
+ }
104
+
105
+
106
+ - (instancetype)initWithFrame:(CGRect)frame
107
+ {
108
+ if (self = [super initWithFrame:frame]) {
109
+ static const auto defaultProps = std::make_shared<const RNMapsMapViewProps>();
110
+ _props = defaultProps;
111
+ _legacyMapManager = [[AIRMapManager alloc] init];
112
+ _view = (AIRMap *)[_legacyMapManager view];
113
+
114
+ self.contentView = _view;
115
+
116
+ _view.onPress = [self](NSDictionary* dictionary) {
117
+ if (_eventEmitter) {
118
+ // Extract values from the NSDictionary
119
+ NSDictionary* coordinateDict = dictionary[@"coordinate"];
120
+ NSDictionary* positionDict = dictionary[@"position"];
121
+
122
+ // Populate the OnMapPressCoordinate struct
123
+ facebook::react::RNMapsMapViewEventEmitter::OnPressCoordinate coordinate = {
124
+ .latitude = [coordinateDict[@"latitude"] doubleValue],
125
+ .longitude = [coordinateDict[@"longitude"] doubleValue],
126
+ };
127
+
128
+ // Populate the OnMapPressPosition struct
129
+ facebook::react::RNMapsMapViewEventEmitter::OnPressPosition position = {
130
+ .x = [positionDict[@"x"] doubleValue],
131
+ .y = [positionDict[@"y"] doubleValue],
132
+ };
133
+
134
+ auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
135
+ facebook::react::RNMapsMapViewEventEmitter::OnPress data = {
136
+ .action = std::string([@"press" UTF8String]),
137
+ .position = position,
138
+ .coordinate = coordinate
139
+ };
140
+ mapViewEventEmitter->onPress(data);
141
+ }
142
+ };
143
+
144
+
145
+ _view.onMapReady = [self](NSDictionary* dictionary) {
146
+ if (_eventEmitter) {
147
+
148
+ auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
149
+ facebook::react::RNMapsMapViewEventEmitter::OnMapReady data = {};
150
+ mapViewEventEmitter->onMapReady(data);
151
+ }
152
+ };
153
+ _view.onChange = [self](NSDictionary* dictionary) {
154
+ if (_eventEmitter) {
155
+
156
+ NSDictionary* regionDict = dictionary[@"region"];
157
+ auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
158
+ facebook::react::RNMapsMapViewEventEmitter::OnRegionChange data = {
159
+ .region.latitude = [regionDict[@"latitude"] doubleValue],
160
+ .region.longitude = [regionDict[@"longitude"] doubleValue],
161
+ .region.latitudeDelta = [regionDict[@"latitudeDelta"] doubleValue],
162
+ .region.longitudeDelta = [regionDict[@"longitudeDelta"] doubleValue],
163
+ .continuous = [dictionary[@"continuous"] boolValue],
164
+ };
165
+ mapViewEventEmitter->onRegionChange(data);
166
+ }
167
+ };
168
+ _view.onDoublePress = [self](NSDictionary* dictionary) {
169
+ if (_eventEmitter) {
170
+
171
+ NSDictionary* coordinateDict = dictionary[@"coordinate"];
172
+ NSDictionary* positionDict = dictionary[@"position"];
173
+
174
+ // Populate the OnMapPressCoordinate struct
175
+ facebook::react::RNMapsMapViewEventEmitter::OnDoublePressCoordinate coordinate = {
176
+ .latitude = [coordinateDict[@"latitude"] doubleValue],
177
+ .longitude = [coordinateDict[@"longitude"] doubleValue],
178
+ };
179
+
180
+ // Populate the OnMapDouplePressPosition struct
181
+ facebook::react::RNMapsMapViewEventEmitter::OnDoublePressPosition position = {
182
+ .x = [positionDict[@"x"] doubleValue],
183
+ .y = [positionDict[@"y"] doubleValue],
184
+ };
185
+
186
+
187
+ auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
188
+ facebook::react::RNMapsMapViewEventEmitter::OnDoublePress data = {
189
+ .position = position,
190
+ .coordinate = coordinate
191
+ };
192
+ mapViewEventEmitter->onDoublePress(data);
193
+ }
194
+ };
195
+
196
+ _view.onPanDrag = [self](NSDictionary* dictionary) {
197
+ if (_eventEmitter) {
198
+
199
+ NSDictionary* coordinateDict = dictionary[@"coordinate"];
200
+ NSDictionary* positionDict = dictionary[@"position"];
201
+
202
+ // Populate the OnMapPressCoordinate struct
203
+ facebook::react::RNMapsMapViewEventEmitter::OnPanDragCoordinate coordinate = {
204
+ .latitude = [coordinateDict[@"latitude"] doubleValue],
205
+ .longitude = [coordinateDict[@"longitude"] doubleValue],
206
+ };
207
+
208
+ // Populate the OnMapDouplePressPosition struct
209
+ facebook::react::RNMapsMapViewEventEmitter::OnPanDragPosition position = {
210
+ .x = [positionDict[@"x"] doubleValue],
211
+ .y = [positionDict[@"y"] doubleValue],
212
+ };
213
+
214
+ auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
215
+ facebook::react::RNMapsMapViewEventEmitter::OnPanDrag data = {
216
+ .position = position,
217
+ .coordinate = coordinate,
218
+ };
219
+ mapViewEventEmitter->onPanDrag(data);
220
+ }
221
+ };
222
+
223
+ _view.onUserLocationChange = [self](NSDictionary* dictionary) {
224
+ if (_eventEmitter) {
225
+
226
+ NSDictionary* coordinateDict = dictionary[@"coordinate"];
227
+ NSDictionary* errorDict = dictionary[@"error"];
228
+
229
+
230
+ // Populate the OnMapPressCoordinate struct
231
+ facebook::react::RNMapsMapViewEventEmitter::OnUserLocationChangeCoordinate coordinate = {
232
+ .latitude = [coordinateDict[@"latitude"] doubleValue],
233
+ .longitude = [coordinateDict[@"longitude"] doubleValue],
234
+ };
235
+ facebook::react::RNMapsMapViewEventEmitter::OnUserLocationChangeError error = {
236
+ .message = std::string([errorDict[@"message"] UTF8String]),
237
+ };
238
+
239
+
240
+ auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
241
+ facebook::react::RNMapsMapViewEventEmitter::OnUserLocationChange data = {
242
+ .coordinate = coordinate,
243
+ .error = error,
244
+ };
245
+ mapViewEventEmitter->onUserLocationChange(data);
246
+ }
247
+ };
248
+
249
+ _view.onCalloutPress = [self](NSDictionary* dictionary) {
250
+ if (_eventEmitter) {
251
+
252
+ NSDictionary* coordinateDict = dictionary[@"coordinate"];
253
+ NSDictionary* positionDict = dictionary[@"position"];
254
+
255
+ // Populate the OnCalloutPressPoint struct
256
+ facebook::react::RNMapsMapViewEventEmitter::OnCalloutPressPoint point = {
257
+ .x = [coordinateDict[@"x"] doubleValue],
258
+ .y = [coordinateDict[@"y"] doubleValue],
259
+ };
260
+
261
+
262
+ facebook::react::RNMapsMapViewEventEmitter::OnCalloutPressFrame frame = {
263
+ .x = [positionDict[@"x"] doubleValue],
264
+ .y = [positionDict[@"y"] doubleValue],
265
+ .width = [positionDict[@"width"] doubleValue],
266
+ .height = [positionDict[@"height"] doubleValue],
267
+ };
268
+
269
+ auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
270
+ facebook::react::RNMapsMapViewEventEmitter::OnCalloutPress data = {
271
+ .action = std::string([dictionary[@"action"] UTF8String]),
272
+ .id = std::string([dictionary[@"id"] UTF8String]),
273
+ .point = point,
274
+ .frame = frame,
275
+ };
276
+ mapViewEventEmitter->onCalloutPress(data);
277
+ }
278
+ };
279
+
280
+
281
+ _view.onRegionChangeStart = [self](NSDictionary* dictionary) {
282
+ if (_eventEmitter) {
283
+
284
+ NSDictionary* regionDict = dictionary[@"region"];
285
+ auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
286
+ facebook::react::RNMapsMapViewEventEmitter::OnRegionChangeStart data = {
287
+ .region.latitude = [regionDict[@"latitude"] doubleValue],
288
+ .region.longitude = [regionDict[@"longitude"] doubleValue],
289
+ .region.latitudeDelta = [regionDict[@"latitudeDelta"] doubleValue],
290
+ .region.longitudeDelta = [regionDict[@"longitudeDelta"] doubleValue],
291
+ .continuous = [dictionary[@"continuous"] boolValue],
292
+ };
293
+ mapViewEventEmitter->onRegionChangeStart(data);
294
+ }
295
+ };
296
+
297
+
298
+ #define HANDLE_MARKER_DRAG_EVENT(eventName, emitterFunction) \
299
+ if (_eventEmitter) { \
300
+ NSDictionary* coordinateDict = dictionary[@"coordinate"]; \
301
+ auto mapViewEventEmitter = \
302
+ std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter); \
303
+ facebook::react::RNMapsMapViewEventEmitter::eventName data = { \
304
+ .coordinate.latitude = [coordinateDict[@"latitude"] doubleValue], \
305
+ .coordinate.longitude = [coordinateDict[@"longitude"] doubleValue], \
306
+ .id = std::string([[dictionary valueForKey:@"id"] UTF8String]), \
307
+ }; \
308
+ mapViewEventEmitter->emitterFunction(data); \
309
+ }
310
+
311
+
312
+
313
+ #define HANDLE_MARKER_EVENT(eventName, emitterFunction, actionName) \
314
+ if (_eventEmitter) { \
315
+ NSDictionary* coordinateDict = dictionary[@"coordinate"]; \
316
+ facebook::react::RNMapsMapViewEventEmitter::eventName##Coordinate coordinate = { \
317
+ .latitude = [coordinateDict[@"latitude"] doubleValue], \
318
+ .longitude = [coordinateDict[@"longitude"] doubleValue], \
319
+ }; \
320
+ \
321
+ auto mapViewEventEmitter = \
322
+ std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter); \
323
+ facebook::react::RNMapsMapViewEventEmitter::eventName data = { \
324
+ .action = std::string([@actionName UTF8String]), \
325
+ .id = std::string([[dictionary valueForKey:@"id"] UTF8String]), \
326
+ .coordinate = coordinate \
327
+ }; \
328
+ mapViewEventEmitter->emitterFunction(data); \
329
+ }
330
+
331
+ _view.onMarkerDrag = [self](NSDictionary* dictionary) {
332
+ HANDLE_MARKER_DRAG_EVENT(OnMarkerDrag, onMarkerDrag);
333
+ };
334
+
335
+ _view.onMarkerDragStart = [self](NSDictionary* dictionary) {
336
+ HANDLE_MARKER_DRAG_EVENT(OnMarkerDragStart, onMarkerDragStart);
337
+ };
338
+
339
+ _view.onMarkerDragEnd = [self](NSDictionary* dictionary) {
340
+ HANDLE_MARKER_DRAG_EVENT(OnMarkerDragEnd, onMarkerDragEnd);
341
+ };
342
+
343
+ _view.onMarkerSelect = [self](NSDictionary* dictionary) {
344
+ HANDLE_MARKER_EVENT(OnMarkerSelect, onMarkerSelect, "marker-select");
345
+ };
346
+
347
+ _view.onMarkerDeselect = [self](NSDictionary* dictionary) {
348
+ HANDLE_MARKER_EVENT(OnMarkerDeselect, onMarkerDeselect, "marker-deselect");
349
+ };
350
+
351
+ _view.onMarkerPress = [self](NSDictionary* dictionary) {
352
+ HANDLE_MARKER_EVENT(OnMarkerPress, onMarkerPress, "marker-press");
353
+ };
354
+
355
+
356
+
357
+ }
358
+
359
+ return self;
360
+ }
361
+
362
+ - (id)getPaperViewFromChildComponentView:(UIView *)childComponentView {
363
+ // Check if the childComponentView responds to the "adapter" selector
364
+ if ([childComponentView respondsToSelector:@selector(paperView)]) {
365
+ // Safely return the paperView
366
+ return [childComponentView valueForKey:@"paperView"];
367
+ }
368
+ // Return nil if paperView is not accessible
369
+ return nil;
370
+ }
371
+
372
+ - (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index{
373
+ id<RCTComponent> paperView = [self getPaperViewFromChildComponentView:childComponentView];
374
+ if (paperView){
375
+ [_view insertReactSubview:paperView atIndex:index];
376
+ }
377
+ }
378
+ - (void) unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
379
+ {
380
+ id<RCTComponent> paperView = [self getPaperViewFromChildComponentView:childComponentView];
381
+ if (paperView){
382
+ [_view removeReactSubview:paperView];
383
+ }
384
+ }
385
+
386
+ MKMapType mapRNTypeToMKMapType(RNMapsMapViewMapType rnMapType) {
387
+ switch (rnMapType) {
388
+ case RNMapsMapViewMapType::Standard: return MKMapTypeStandard;
389
+ case RNMapsMapViewMapType::Satellite: return MKMapTypeSatellite;
390
+ case RNMapsMapViewMapType::Hybrid: return MKMapTypeHybrid;
391
+ case RNMapsMapViewMapType::MutedStandard: return MKMapTypeMutedStandard;
392
+ case RNMapsMapViewMapType::SatelliteFlyover: return MKMapTypeSatelliteFlyover;
393
+ case RNMapsMapViewMapType::HybridFlyover: return MKMapTypeHybridFlyover;
394
+ default: return MKMapTypeStandard; // Default case
395
+ }
396
+ }
397
+
398
+
399
+ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
400
+ {
401
+ const auto &oldViewProps = *std::static_pointer_cast<RNMapsMapViewProps const>(_props);
402
+ const auto &newViewProps = *std::static_pointer_cast<RNMapsMapViewProps const>(props);
403
+
404
+ #define REMAP_MAPVIEW_PROP(name) \
405
+ if (oldViewProps.name != newViewProps.name) { \
406
+ _view.name = newViewProps.name; \
407
+ }
408
+
409
+ #define REMAP_MAPVIEW_STRING_PROP(name) \
410
+ if (oldViewProps.name != newViewProps.name) { \
411
+ _view.name = RCTNSStringFromString(newViewProps.name); \
412
+ }
413
+
414
+ #define REMAP_MAPVIEW_COLOR_PROP(name) \
415
+ if (oldViewProps.name != newViewProps.name) { \
416
+ _view.name = RCTUIColorFromSharedColor(newViewProps.name); \
417
+ }
418
+
419
+ #define REMAP_MAPVIEW_POINT_PROP(name) \
420
+ if (newViewProps.name.x != oldViewProps.name.x || \
421
+ newViewProps.name.y != oldViewProps.name.y) { \
422
+ _view.name = CGPointMake(newViewProps.name.x, newViewProps.name.y); \
423
+ }
424
+
425
+ #define REMAP_MAPVIEW_REGION_PROP(name) \
426
+ if (newViewProps.name.latitude != oldViewProps.name.latitude || \
427
+ newViewProps.name.longitude != oldViewProps.name.longitude || \
428
+ newViewProps.name.latitudeDelta != oldViewProps.name.latitudeDelta ||\
429
+ newViewProps.name.longitudeDelta != oldViewProps.name.longitudeDelta) { \
430
+ MKCoordinateSpan span = MKCoordinateSpanMake(newViewProps.name.latitudeDelta, \
431
+ newViewProps.name.longitudeDelta); \
432
+ MKCoordinateRegion region = MKCoordinateRegionMake(CLLocationCoordinate2DMake( \
433
+ newViewProps.name.latitude, newViewProps.name.longitude), span); \
434
+ _view.name = region; \
435
+ }
436
+
437
+ #define REMAP_MAPVIEW_CAMERA_PROP(name) \
438
+ if (newViewProps.name.center.latitude != oldViewProps.name.center.latitude || \
439
+ newViewProps.name.center.longitude != oldViewProps.name.center.longitude || \
440
+ newViewProps.name.heading != oldViewProps.name.heading || \
441
+ newViewProps.name.pitch != oldViewProps.name.pitch) { \
442
+ CLLocationCoordinate2D center = CLLocationCoordinate2DMake( \
443
+ newViewProps.name.center.latitude, \
444
+ newViewProps.name.center.longitude); \
445
+ MKMapCamera* camera = [[MKMapCamera alloc] init]; \
446
+ camera.centerCoordinate = center; \
447
+ camera.heading = newViewProps.name.heading; \
448
+ camera.pitch = newViewProps.name.pitch; \
449
+ _view.name = camera; \
450
+ }
451
+
452
+ #define REMAP_MAPVIEW_EDGEINSETS_PROP(name) \
453
+ if (newViewProps.name.top != oldViewProps.name.top || \
454
+ newViewProps.name.right != oldViewProps.name.right || \
455
+ newViewProps.name.bottom != oldViewProps.name.bottom || \
456
+ newViewProps.name.left != oldViewProps.name.left) { \
457
+ _view.name = UIEdgeInsetsMake(newViewProps.name.top, \
458
+ newViewProps.name.left, \
459
+ newViewProps.name.bottom, \
460
+ newViewProps.name.right); \
461
+ }
462
+
463
+ #define REMAP_MAPVIEW_MAPTYPE(rnMapType) MKMapType##rnMapType
464
+
465
+
466
+ REMAP_MAPVIEW_PROP(cacheEnabled)
467
+
468
+ REMAP_MAPVIEW_PROP(followsUserLocation)
469
+ REMAP_MAPVIEW_PROP(loadingEnabled)
470
+ REMAP_MAPVIEW_PROP(scrollEnabled)
471
+
472
+ REMAP_MAPVIEW_PROP(maxDelta)
473
+ REMAP_MAPVIEW_PROP(maxZoom)
474
+ REMAP_MAPVIEW_PROP(minDelta)
475
+ REMAP_MAPVIEW_PROP(minZoom)
476
+
477
+ REMAP_MAPVIEW_PROP(showsCompass)
478
+ REMAP_MAPVIEW_PROP(showsScale)
479
+ REMAP_MAPVIEW_PROP(showsTraffic)
480
+ REMAP_MAPVIEW_PROP(showsUserLocation)
481
+ REMAP_MAPVIEW_PROP(userLocationCalloutEnabled)
482
+ REMAP_MAPVIEW_PROP(zoomEnabled)
483
+
484
+ REMAP_MAPVIEW_POINT_PROP(compassOffset)
485
+
486
+ REMAP_MAPVIEW_REGION_PROP(region)
487
+ REMAP_MAPVIEW_REGION_PROP(initialRegion)
488
+
489
+ REMAP_MAPVIEW_CAMERA_PROP(initialCamera)
490
+ REMAP_MAPVIEW_CAMERA_PROP(camera)
491
+
492
+ REMAP_MAPVIEW_EDGEINSETS_PROP(legalLabelInsets)
493
+ REMAP_MAPVIEW_EDGEINSETS_PROP(mapPadding)
494
+
495
+ REMAP_MAPVIEW_COLOR_PROP(loadingIndicatorColor)
496
+ REMAP_MAPVIEW_COLOR_PROP(loadingIndicatorColor)
497
+ REMAP_MAPVIEW_COLOR_PROP(tintColor)
498
+
499
+ REMAP_MAPVIEW_STRING_PROP(userLocationAnnotationTitle)
500
+
501
+ if (oldViewProps.mapType != newViewProps.mapType){
502
+ _view.mapType = mapRNTypeToMKMapType(newViewProps.mapType);
503
+ }
504
+ if (oldViewProps.userInterfaceStyle != newViewProps.userInterfaceStyle){
505
+ switch (newViewProps.userInterfaceStyle) {
506
+ case RNMapsMapViewUserInterfaceStyle::Light:
507
+ _view.overrideUserInterfaceStyle = UIUserInterfaceStyleLight;
508
+ break;
509
+ case RNMapsMapViewUserInterfaceStyle::Dark:
510
+ _view.overrideUserInterfaceStyle = UIUserInterfaceStyleDark;
511
+ break;
512
+ case RNMapsMapViewUserInterfaceStyle::System:
513
+ _view.overrideUserInterfaceStyle = UIUserInterfaceStyleUnspecified;
514
+ break;
515
+ }
516
+ }
517
+
518
+ if (oldViewProps.cameraZoomRange.minCenterCoordinateDistance != newViewProps.cameraZoomRange.minCenterCoordinateDistance ||
519
+ oldViewProps.cameraZoomRange.maxCenterCoordinateDistance != newViewProps.cameraZoomRange.maxCenterCoordinateDistance ||
520
+ oldViewProps.cameraZoomRange.animated != newViewProps.cameraZoomRange.animated) {
521
+
522
+ MKMapCameraZoomRange* zoomRange = [[MKMapCameraZoomRange alloc] initWithMinCenterCoordinateDistance:newViewProps.cameraZoomRange.minCenterCoordinateDistance maxCenterCoordinateDistance:newViewProps.cameraZoomRange.maxCenterCoordinateDistance];
523
+ [_view setCameraZoomRange:zoomRange animated:newViewProps.cameraZoomRange.animated];
524
+ }
525
+
526
+
527
+ [super updateProps:props oldProps:oldProps];
528
+ }
529
+
530
+ @end
531
+
532
+ Class<RCTComponentViewProtocol> RNMapsMapViewCls(void)
533
+ {
534
+ return RNMapsMapView.class;
535
+ }
@@ -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 */,
@@ -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
  /**
package/lib/MapView.d.ts CHANGED
@@ -11,7 +11,7 @@ export type MapViewProps = ViewProps & {
11
11
  * If `true` map will be cached and displayed as an image instead of being interactable, for performance usage.
12
12
  *
13
13
  * @default false
14
- * @platform iOS: Apple maps only
14
+ * @platform iOS: Apple Maps only
15
15
  * @platform Android: Supported
16
16
  */
17
17
  cacheEnabled?: boolean;
@@ -92,7 +92,7 @@ export type MapViewProps = ViewProps & {
92
92
  */
93
93
  kmlSrc?: string;
94
94
  /**
95
- * If set, changes the position of the "Legal" label link in Apple maps.
95
+ * If set, changes the position of the "Legal" label link in Apple Maps.
96
96
  *
97
97
  * @platform iOS: Apple Maps only
98
98
  * @platform Android: Not supported
@@ -615,6 +615,7 @@ type State = {
615
615
  declare class MapView extends React.Component<MapViewProps, State> {
616
616
  static Animated: Animated.AnimatedComponent<typeof MapView>;
617
617
  private map;
618
+ private fabricMap;
618
619
  constructor(props: MapViewProps);
619
620
  setNativeProps(props: Partial<NativeProps>): void;
620
621
  private _onMapReady;
@@ -702,9 +703,12 @@ declare class MapView extends React.Component<MapViewProps, State> {
702
703
  * @return Object Object bounding box ({ northEast: <LatLng>, southWest: <LatLng> })
703
704
  */
704
705
  boundingBoxForRegion(region: Region): BoundingBox;
705
- private _mapManagerCommand;
706
706
  private _getHandle;
707
- private _runCommand;
707
+ private handleMapPress;
708
+ private handleMarkerPress;
709
+ private handleMarkerSelect;
710
+ private handleMarkerDeselect;
711
+ private handleRegionChange;
708
712
  render(): React.JSX.Element;
709
713
  }
710
714
  export declare const AnimatedMapView: RNAnimated.AnimatedComponent<typeof MapView>;