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

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 (64) 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/AIRGoogleMap.h +8 -2
  5. package/ios/AirGoogleMaps/AIRGoogleMap.m +166 -11
  6. package/ios/AirGoogleMaps/AIRGoogleMapCircle.h +0 -1
  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 +28 -119
  11. package/ios/AirGoogleMaps/AIRGoogleMapMarker.h +2 -0
  12. package/ios/AirGoogleMaps/AIRGoogleMapMarker.m +344 -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 +29 -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 -4
  32. package/ios/AirMaps/AIRMap.m +227 -137
  33. package/ios/AirMaps/AIRMapManager.m +9 -21
  34. package/ios/AirMaps/AIRMapMarker.h +1 -0
  35. package/ios/AirMaps/AIRMapMarker.m +58 -2
  36. package/ios/AirMaps/RCTConvert+AirMap.h +4 -0
  37. package/ios/AirMaps/RCTConvert+AirMap.m +2 -0
  38. package/ios/AirMaps/RNMapsAirModule.h +3 -0
  39. package/ios/AirMaps/RNMapsAirModule.mm +40 -171
  40. package/ios/AirMaps/RNMapsAirModuleDelegate.h +24 -0
  41. package/ios/AirMaps/RNMapsHostVewDelegate.h +17 -0
  42. package/ios/AirMaps/RNMapsMapView.h +6 -3
  43. package/ios/AirMaps/RNMapsMapView.mm +340 -334
  44. package/ios/AirMaps/UIView +AirMap.m +20 -0
  45. package/ios/AirMaps/UIView+AirMap.h +11 -0
  46. package/lib/MapMarker.d.ts +3 -2
  47. package/lib/MapMarker.js +52 -10
  48. package/lib/MapMarkerNativeComponent.js +0 -2
  49. package/lib/MapOverlay.d.ts +1 -1
  50. package/lib/MapView.d.ts +4 -22
  51. package/lib/MapView.js +28 -21
  52. package/lib/{FabricMapView.d.ts → createFabricMap.d.ts} +7 -6
  53. package/lib/createFabricMap.js +175 -0
  54. package/lib/decorateMapComponent.js +18 -0
  55. package/lib/specs/NativeComponentGoogleMapView.d.ts +713 -0
  56. package/lib/specs/NativeComponentGoogleMapView.js +21 -0
  57. package/lib/specs/NativeComponentGooglePolygon.d.ts +75 -0
  58. package/lib/specs/NativeComponentGooglePolygon.js +9 -0
  59. package/lib/specs/NativeComponentMapView.d.ts +21 -45
  60. package/lib/specs/NativeComponentMarker.d.ts +246 -0
  61. package/lib/specs/NativeComponentMarker.js +21 -0
  62. package/package.json +10 -7
  63. package/react-native-maps.podspec +1 -1
  64. package/lib/FabricMapView.js +0 -175
@@ -14,6 +14,8 @@
14
14
  #import <React/RCTImageLoaderProtocol.h>
15
15
  #import <React/RCTUtils.h>
16
16
  #import <React/UIView+React.h>
17
+ #import <React/RCTImageLoader.h>
18
+ #import <React/RCTBridge+Private.h>
17
19
 
18
20
  NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
19
21
 
@@ -28,6 +30,13 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
28
30
  BOOL _calloutIsOpen;
29
31
  NSInteger _zIndexBeforeOpen;
30
32
  BOOL _useLegacyPinView;
33
+
34
+ CADisplayLink *_displayLink;
35
+ CLLocationCoordinate2D _startCoordinate;
36
+ CLLocationCoordinate2D _endCoordinate;
37
+ NSTimeInterval _animationStartTime;
38
+ NSTimeInterval _animationDuration;
39
+ BOOL _isAnimating;
31
40
  }
32
41
 
33
42
  - (instancetype)initWithFrame:(CGRect)frame {
@@ -68,6 +77,7 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
68
77
  self.calloutView = (AIRMapCallout *)subview;
69
78
  } else {
70
79
  [super insertReactSubview:(UIView *)subview atIndex:atIndex];
80
+ [self addSubview:subview];
71
81
  }
72
82
  }
73
83
  - (void) setFrame:(CGRect)frame {
@@ -84,6 +94,7 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
84
94
  self.calloutView = nil;
85
95
  } else {
86
96
  [super removeReactSubview:(UIView *)subview];
97
+ [(UIView *) subview removeFromSuperview];
87
98
  }
88
99
  }
89
100
 
@@ -344,7 +355,8 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
344
355
  _reloadImageCancellationBlock();
345
356
  _reloadImageCancellationBlock = nil;
346
357
  }
347
- _reloadImageCancellationBlock = [[_bridge moduleForName:@"ImageLoader"] loadImageWithURLRequest:[RCTConvert NSURLRequest:_imageSrc]
358
+
359
+ _reloadImageCancellationBlock = [[[RCTBridge currentBridge] moduleForName:@"ImageLoader"] loadImageWithURLRequest:[RCTConvert NSURLRequest:_imageSrc]
348
360
  size:self.bounds.size
349
361
  scale:RCTScreenScale()
350
362
  clipped:YES
@@ -352,9 +364,10 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
352
364
  progressBlock:nil
353
365
  partialLoadBlock:nil
354
366
  completionBlock:^(NSError *error, UIImage *image) {
367
+ NSLog(@"image load completed");
355
368
  if (error) {
356
369
  // TODO(lmr): do something with the error?
357
- NSLog(@"%@", error);
370
+ NSLog(@"failed to load image: %@", error);
358
371
  }
359
372
  dispatch_async(dispatch_get_main_queue(), ^{
360
373
  self.image = image;
@@ -398,4 +411,47 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
398
411
  _useLegacyPinView = value;
399
412
  }
400
413
 
414
+ - (void)animateToCoordinate:(CLLocationCoordinate2D)newCoordinate duration:(NSTimeInterval)duration {
415
+ if (_isAnimating) {
416
+ NSLog(@"Animation already in progress. Rejecting new animation request.");
417
+ return;
418
+ }
419
+
420
+ // Mark as animating
421
+ _isAnimating = YES;
422
+
423
+ // Store animation parameters
424
+ _startCoordinate = self.coordinate;
425
+ _endCoordinate = newCoordinate;
426
+ _animationDuration = duration;
427
+ _animationStartTime = [NSDate timeIntervalSinceReferenceDate];
428
+
429
+ // Start a CADisplayLink
430
+ if (_displayLink) {
431
+ [_displayLink invalidate];
432
+ }
433
+ _displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(updatePosition)];
434
+ [_displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
435
+ }
436
+
437
+ - (void)updatePosition {
438
+ NSTimeInterval elapsed = [NSDate timeIntervalSinceReferenceDate] - _animationStartTime;
439
+ CGFloat progress = MIN(elapsed / _animationDuration, 1.0);
440
+
441
+ // Interpolate coordinates
442
+ CLLocationDegrees currentLatitude = _startCoordinate.latitude + progress * (_endCoordinate.latitude - _startCoordinate.latitude);
443
+ CLLocationDegrees currentLongitude = _startCoordinate.longitude + progress * (_endCoordinate.longitude - _startCoordinate.longitude);
444
+
445
+ // Update annotation's coordinate
446
+ CLLocationCoordinate2D currentCoordinate = CLLocationCoordinate2DMake(currentLatitude, currentLongitude);
447
+ [self setValue:[NSValue valueWithMKCoordinate:currentCoordinate] forKey:@"coordinate"];
448
+
449
+ // Stop the animation when complete
450
+ if (progress == 1.0) {
451
+ [_displayLink invalidate];
452
+ _displayLink = nil;
453
+ _isAnimating = NO; // Reset the animation state
454
+ }
455
+ }
456
+
401
457
  @end
@@ -7,6 +7,8 @@
7
7
  #import <MapKit/MapKit.h>
8
8
  #import <React/RCTConvert.h>
9
9
 
10
+ @class AIRMapCoordinate;
11
+
10
12
  @interface RCTConvert (AirMap)
11
13
 
12
14
  + (MKCoordinateSpan)MKCoordinateSpan:(id)json;
@@ -16,4 +18,6 @@
16
18
  + (MKMapType)MKMapType:(id)json;
17
19
  + (NSDictionary*) dictonaryFromString:(NSString *) str;
18
20
  + (NSArray*) arrayFromString:(NSString *) str;
21
+ + (NSArray<NSArray<AIRMapCoordinate *> *> *)AIRMapCoordinateArrayArray:(id)json;
22
+ + (AIRMapCoordinate*) AIRMapCoordinate:(id)json;
19
23
  @end
@@ -27,6 +27,7 @@
27
27
  };
28
28
  }
29
29
 
30
+
30
31
  + (MKMapCamera*)MKMapCamera:(id)json
31
32
  {
32
33
  json = [self NSDictionary:json];
@@ -49,6 +50,7 @@
49
50
  error:&jsonError];
50
51
  }
51
52
 
53
+
52
54
  + (MKMapCamera*)MKMapCameraWithDefaults:(id)json existingCamera:(MKMapCamera*)camera
53
55
  {
54
56
  json = [self NSDictionary:json];
@@ -1,5 +1,6 @@
1
1
  // RCTNativeLocalStorage.h
2
2
  // TurboModuleExample
3
+ #ifdef RCT_NEW_ARCH_ENABLED
3
4
 
4
5
  #import <Foundation/Foundation.h>
5
6
  #import <RNMapsSpecs/RNMapsSpecs.h>
@@ -11,3 +12,5 @@ NS_ASSUME_NONNULL_BEGIN
11
12
  @end
12
13
 
13
14
  NS_ASSUME_NONNULL_END
15
+
16
+ #endif
@@ -20,15 +20,15 @@
20
20
  @synthesize viewRegistry_DEPRECATED = _viewRegistry_DEPRECATED;
21
21
 
22
22
  - (void)executeWithMapView:(double)tag
23
- success:(void (^)(AIRMap *mapView))success
23
+ success:(void (^)(id<RNMapsAirModuleDelegate> mapView))success
24
24
  reject:(RCTPromiseRejectBlock)reject {
25
25
  dispatch_async(dispatch_get_main_queue(), ^{
26
26
  id view = [_viewRegistry_DEPRECATED viewForReactTag:[NSNumber numberWithDouble:tag]];
27
- if (![view isKindOfClass:[RNMapsMapView class]]) {
28
- reject(@"Invalid argument", [NSString stringWithFormat:@"Invalid view returned from registry, expecting RNMapsMapView, got: %@", view], NULL);
27
+ if ([view conformsToProtocol:@protocol(RNMapsHostVewDelegate)]) {
28
+ id<RNMapsAirModuleDelegate> mapViewDelegate = [view mapView];
29
+ success(mapViewDelegate);
29
30
  } else {
30
- AIRMap *mapView = [view mapView];
31
- success(mapView);
31
+ reject(@"Invalid argument", [NSString stringWithFormat:@"Invalid view returned from registry, expecting RNMapsMapView, got: %@", view], NULL);
32
32
  }
33
33
  });
34
34
  }
@@ -36,17 +36,8 @@
36
36
  - (void)getCamera:(double)tag
37
37
  resolve:(RCTPromiseResolveBlock)resolve
38
38
  reject:(RCTPromiseRejectBlock)reject {
39
- [self executeWithMapView:tag success:^(AIRMap *mapView) {
40
- MKMapCamera *camera = [mapView camera];
41
- resolve(@{
42
- @"center": @{
43
- @"latitude": @(camera.centerCoordinate.latitude),
44
- @"longitude": @(camera.centerCoordinate.longitude),
45
- },
46
- @"pitch": @(camera.pitch),
47
- @"heading": @(camera.heading),
48
- @"altitude": @(camera.altitude),
49
- });
39
+ [self executeWithMapView:tag success:^(id<RNMapsAirModuleDelegate> mapView) {
40
+ resolve([mapView getCamera]);
50
41
  } reject:reject];
51
42
 
52
43
  }
@@ -56,7 +47,7 @@
56
47
  resolve:(RCTPromiseResolveBlock)resolve
57
48
  reject:(RCTPromiseRejectBlock)reject
58
49
  {
59
- [self executeWithMapView:tag success:^(AIRMap *mapView) {
50
+ [self executeWithMapView:tag success:^(id<RNMapsAirModuleDelegate> mapView) {
60
51
  resolve([mapView getMarkersFramesWithOnlyVisible:onlyVisible]);
61
52
  } reject:reject];
62
53
  }
@@ -64,7 +55,7 @@
64
55
  resolve:(RCTPromiseResolveBlock)resolve
65
56
  reject:(RCTPromiseRejectBlock)reject
66
57
  {
67
- [self executeWithMapView:tag success:^(AIRMap *mapView) {
58
+ [self executeWithMapView:tag success:^(id<RNMapsAirModuleDelegate> mapView) {
68
59
  resolve([mapView getMapBoundaries]);
69
60
  } reject:reject];
70
61
  }
@@ -73,42 +64,11 @@
73
64
  resolve:(RCTPromiseResolveBlock)resolve
74
65
  reject:(RCTPromiseRejectBlock)reject
75
66
  {
76
-
77
- [self executeWithMapView:tag success:^(AIRMap *mapView) {
78
-
79
- MKMapSnapshotOptions *options = [[MKMapSnapshotOptions alloc] init];
80
-
81
- options.mapType = mapView.mapType;
82
- NSNumber *width = config[@"width"];
83
- NSNumber *height = config[@"height"];
84
- NSNumber *quality = config[@"quality"];
85
- NSString*format =config[@"format"];
86
- NSString*result =config[@"result"];
87
- MKCoordinateRegion region = [RCTConvert MKCoordinateRegion:config[@"region"]];
88
-
89
-
90
- options.region = (region.center.latitude && region.center.longitude) ? region : mapView.region;
91
- options.size = CGSizeMake(
92
- ([width floatValue] == 0) ? mapView.bounds.size.width : [width floatValue],
93
- ([height floatValue] == 0) ? mapView.bounds.size.height : [height floatValue]
94
- );
95
-
96
- options.scale = [[UIScreen mainScreen] scale];
97
-
98
-
99
- MKMapSnapshotter *snapshotter = [[MKMapSnapshotter alloc] initWithOptions:options];
100
-
101
- [self takeMapSnapshot:mapView
102
- snapshotter:snapshotter
103
- format:format
104
- quality:[quality floatValue]
105
- result:result
106
- callback:resolve];
107
-
67
+ [self executeWithMapView:tag success:^(id<RNMapsAirModuleDelegate> mapView) {
68
+ [mapView takeSnapshotWithConfig:config callback:resolve];
108
69
  } reject:reject];
109
-
110
-
111
70
  }
71
+
112
72
  - (void)getAddressFromCoordinates:(double)tag
113
73
  coordinate:(JS::NativeAirMapsModule::LatLng &)coordinate
114
74
  resolve:(RCTPromiseResolveBlock)resolve
@@ -117,32 +77,30 @@
117
77
  double latitude = coordinate.latitude();
118
78
  double longitude = coordinate.longitude();
119
79
 
120
- [self executeWithMapView:tag success:^(AIRMap *mapView) {
121
- CLLocation *location = [[CLLocation alloc] initWithLatitude:latitude
80
+
81
+ CLLocation *location = [[CLLocation alloc] initWithLatitude:latitude
122
82
  longitude:longitude];
123
- CLGeocoder *geoCoder = [[CLGeocoder alloc] init];
124
- [geoCoder reverseGeocodeLocation:location
83
+ CLGeocoder *geoCoder = [[CLGeocoder alloc] init];
84
+ [geoCoder reverseGeocodeLocation:location
125
85
  completionHandler:^(NSArray *placemarks, NSError *error) {
126
- if (error == nil && [placemarks count] > 0){
127
- CLPlacemark *placemark = placemarks[0];
128
- resolve(@{
129
- @"name" : [NSString stringWithFormat:@"%@", placemark.name],
130
- @"thoroughfare" : [NSString stringWithFormat:@"%@", placemark.thoroughfare],
131
- @"subThoroughfare" : [NSString stringWithFormat:@"%@", placemark.subThoroughfare],
132
- @"locality" : [NSString stringWithFormat:@"%@", placemark.locality],
133
- @"subLocality" : [NSString stringWithFormat:@"%@", placemark.subLocality],
134
- @"administrativeArea" : [NSString stringWithFormat:@"%@", placemark.administrativeArea],
135
- @"subAdministrativeArea" : [NSString stringWithFormat:@"%@", placemark.subAdministrativeArea],
136
- @"postalCode" : [NSString stringWithFormat:@"%@", placemark.postalCode],
137
- @"countryCode" : [NSString stringWithFormat:@"%@", placemark.ISOcountryCode],
138
- @"country" : [NSString stringWithFormat:@"%@", placemark.country],
139
- });
140
- } else {
141
- reject(@"Invalid argument", [NSString stringWithFormat:@"Can not get address location"], NULL);
142
- }
143
- }];
144
-
145
- } reject:reject];
86
+ if (error == nil && [placemarks count] > 0){
87
+ CLPlacemark *placemark = placemarks[0];
88
+ resolve(@{
89
+ @"name" : [NSString stringWithFormat:@"%@", placemark.name],
90
+ @"thoroughfare" : [NSString stringWithFormat:@"%@", placemark.thoroughfare],
91
+ @"subThoroughfare" : [NSString stringWithFormat:@"%@", placemark.subThoroughfare],
92
+ @"locality" : [NSString stringWithFormat:@"%@", placemark.locality],
93
+ @"subLocality" : [NSString stringWithFormat:@"%@", placemark.subLocality],
94
+ @"administrativeArea" : [NSString stringWithFormat:@"%@", placemark.administrativeArea],
95
+ @"subAdministrativeArea" : [NSString stringWithFormat:@"%@", placemark.subAdministrativeArea],
96
+ @"postalCode" : [NSString stringWithFormat:@"%@", placemark.postalCode],
97
+ @"countryCode" : [NSString stringWithFormat:@"%@", placemark.ISOcountryCode],
98
+ @"country" : [NSString stringWithFormat:@"%@", placemark.country],
99
+ });
100
+ } else {
101
+ reject(@"Invalid argument", [NSString stringWithFormat:@"Can not get address location"], NULL);
102
+ }
103
+ }];
146
104
  }
147
105
 
148
106
  - (void)getPointForCoordinate:(double)tag
@@ -153,16 +111,10 @@
153
111
  double latitude = coordinate.latitude();
154
112
  double longitude = coordinate.longitude();
155
113
 
156
- [self executeWithMapView:tag success:^(AIRMap *mapView) {
114
+ CLLocationCoordinate2D location = CLLocationCoordinate2DMake(latitude,longitude);
157
115
 
158
- CGPoint touchPoint = [mapView convertCoordinate:
159
- CLLocationCoordinate2DMake(latitude,longitude)
160
- toPointToView:mapView];
161
-
162
- resolve(@{
163
- @"x": @(touchPoint.x),
164
- @"y": @(touchPoint.y),
165
- });
116
+ [self executeWithMapView:tag success:^(id<RNMapsAirModuleDelegate> mapView) {
117
+ resolve([mapView getPointForCoordinates:location]);
166
118
 
167
119
  } reject:reject];
168
120
 
@@ -174,20 +126,10 @@
174
126
  {
175
127
  double x = point.x();
176
128
  double y = point.y();
177
-
178
- [self executeWithMapView:tag success:^(AIRMap *mapView) {
179
-
180
-
181
- CLLocationCoordinate2D coordinate = [mapView convertPoint:CGPointMake(x,y)
182
- toCoordinateFromView:mapView];
183
-
184
- resolve(@{
185
- @"latitude": @(coordinate.latitude),
186
- @"longitude": @(coordinate.longitude),
187
- });
188
-
129
+ CGPoint pt = CGPointMake(x,y);
130
+ [self executeWithMapView:tag success:^(id<RNMapsAirModuleDelegate> mapView) {
131
+ resolve([mapView getCoordinatesForPoint:pt]);
189
132
  } reject:reject];
190
-
191
133
 
192
134
  }
193
135
 
@@ -201,80 +143,7 @@
201
143
  return nil;
202
144
  }
203
145
 
204
- #pragma mark Take Snapshot
205
- - (void)takeMapSnapshot:(AIRMap *)mapView
206
- snapshotter:(MKMapSnapshotter *) snapshotter
207
- format:(NSString *)format
208
- quality:(CGFloat) quality
209
- result:(NSString *)result
210
- callback:(RCTPromiseResolveBlock) callback {
211
- NSTimeInterval timeStamp = [[NSDate date] timeIntervalSince1970];
212
- NSString *pathComponent = [NSString stringWithFormat:@"Documents/snapshot-%.20lf.%@", timeStamp, format];
213
- NSString *filePath = [NSHomeDirectory() stringByAppendingPathComponent: pathComponent];
214
-
215
- [snapshotter startWithQueue:dispatch_get_main_queue()
216
- completionHandler:^(MKMapSnapshot *snapshot, NSError *error) {
217
- if (error) {
218
- callback(@[error]);
219
- return;
220
- }
221
- MKAnnotationView *pin = [[MKPinAnnotationView alloc] initWithAnnotation:nil reuseIdentifier:nil];
222
-
223
- UIImage *image = snapshot.image;
224
- UIGraphicsBeginImageContextWithOptions(image.size, YES, image.scale);
225
- {
226
- [image drawAtPoint:CGPointMake(0.0f, 0.0f)];
227
-
228
- CGRect rect = CGRectMake(0.0f, 0.0f, image.size.width, image.size.height);
229
146
 
230
- for (id <AIRMapSnapshot> overlay in mapView.overlays) {
231
- if ([overlay respondsToSelector:@selector(drawToSnapshot:context:)]) {
232
- [overlay drawToSnapshot:snapshot context:UIGraphicsGetCurrentContext()];
233
- }
234
- }
235
-
236
- for (id <MKAnnotation> annotation in mapView.annotations) {
237
- CGPoint point = [snapshot pointForCoordinate:annotation.coordinate];
238
-
239
- MKAnnotationView* anView = [mapView viewForAnnotation: annotation];
240
-
241
- if (anView){
242
- pin = anView;
243
- }
244
-
245
- if (CGRectContainsPoint(rect, point)) {
246
- point.x = point.x + pin.centerOffset.x - (pin.bounds.size.width / 2.0f);
247
- point.y = point.y + pin.centerOffset.y - (pin.bounds.size.height / 2.0f);
248
- if (pin.image) {
249
- [pin.image drawAtPoint:point];
250
- } else {
251
- CGRect pinRect = CGRectMake(point.x, point.y, pin.bounds.size.width, pin.bounds.size.height);
252
- [pin drawViewHierarchyInRect:pinRect afterScreenUpdates:NO];
253
- }
254
- }
255
- }
256
-
257
- UIImage *compositeImage = UIGraphicsGetImageFromCurrentImageContext();
258
-
259
- NSData *data;
260
- if ([format isEqualToString:@"png"]) {
261
- data = UIImagePNGRepresentation(compositeImage);
262
- }
263
- else if([format isEqualToString:@"jpg"]) {
264
- data = UIImageJPEGRepresentation(compositeImage, quality);
265
- }
266
-
267
- if ([result isEqualToString:@"file"]) {
268
- [data writeToFile:filePath atomically:YES];
269
- callback(filePath);
270
- }
271
- else if ([result isEqualToString:@"base64"]) {
272
- callback([data base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithCarriageReturn]);
273
- }
274
- }
275
- UIGraphicsEndImageContext();
276
- }];
277
- }
278
147
 
279
148
  @end
280
149
 
@@ -0,0 +1,24 @@
1
+ //
2
+ // AIRUrlTileOverlay.h
3
+ // AirMaps
4
+ //
5
+ // Created by cascadian on 3/19/16.
6
+ // Copyright © 2016. All rights reserved.
7
+ //
8
+
9
+ #import <Foundation/Foundation.h>
10
+ #import <CoreLocation/CoreLocation.h>
11
+ #import <React/RCTBridge.h>
12
+
13
+ @protocol RNMapsAirModuleDelegate <NSObject>
14
+ @required
15
+
16
+ - (void)takeSnapshotWithConfig:(NSDictionary *)config
17
+ callback:(RCTPromiseResolveBlock) callback;
18
+
19
+ - (NSDictionary *) getCamera;
20
+ - (NSDictionary*) getMarkersFramesWithOnlyVisible:(BOOL)onlyVisible;
21
+ - (NSArray *) getMapBoundaries;
22
+ - (NSDictionary *) getPointForCoordinates:(CLLocationCoordinate2D) location;
23
+ - (NSDictionary *) getCoordinatesForPoint:(CGPoint) point;
24
+ @end
@@ -0,0 +1,17 @@
1
+ //
2
+ // AIRUrlTileOverlay.h
3
+ // AirMaps
4
+ //
5
+ // Created by cascadian on 3/19/16.
6
+ // Copyright © 2016. All rights reserved.
7
+ //
8
+
9
+ #import <Foundation/Foundation.h>
10
+ #import "RNMapsAirModuleDelegate.h"
11
+
12
+ @protocol RNMapsHostVewDelegate <NSObject>
13
+ @required
14
+
15
+ - (id<RNMapsAirModuleDelegate>) mapView;
16
+
17
+ @end
@@ -5,17 +5,20 @@
5
5
  // Created by Salah Ghanim on 23.11.24.
6
6
  // Copyright © 2024 react-native-maps. All rights reserved.
7
7
  //
8
+ #ifdef RCT_NEW_ARCH_ENABLED
8
9
 
9
10
  #import <React/RCTViewComponentView.h>
10
11
  #import <UIKit/UIKit.h>
12
+ #import "RNMapsHostVewDelegate.h"
13
+
11
14
  @class AIRMap;
12
15
 
13
16
  NS_ASSUME_NONNULL_BEGIN
14
17
 
15
- @interface RNMapsMapView : RCTViewComponentView
16
-
17
- - (AIRMap *) mapView;
18
+ @interface RNMapsMapView : RCTViewComponentView<RNMapsHostVewDelegate>
18
19
 
19
20
  @end
20
21
 
21
22
  NS_ASSUME_NONNULL_END
23
+
24
+ #endif