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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/android/src/main/java/com/rnmaps/fabric/NativeAirMapsModule.java +51 -0
  2. package/android/src/main/java/com/rnmaps/maps/MapAirModulePackage.java +46 -0
  3. package/ios/AirGoogleMaps/AIRGoogleMap.h +8 -2
  4. package/ios/AirGoogleMaps/AIRGoogleMap.m +179 -11
  5. package/ios/AirGoogleMaps/AIRGoogleMapCircle.h +0 -1
  6. package/ios/AirGoogleMaps/AIRGoogleMapCircle.m +23 -11
  7. package/ios/AirGoogleMaps/AIRGoogleMapCoordinate.h +13 -0
  8. package/ios/AirGoogleMaps/AIRGoogleMapCoordinate.m +10 -0
  9. package/ios/AirGoogleMaps/AIRGoogleMapManager.h +7 -0
  10. package/ios/AirGoogleMaps/AIRGoogleMapManager.m +30 -119
  11. package/ios/AirGoogleMaps/AIRGoogleMapMarker.h +2 -0
  12. package/ios/AirGoogleMaps/AIRGoogleMapMarker.m +347 -243
  13. package/ios/AirGoogleMaps/AIRGoogleMapMarkerManager.m +0 -1
  14. package/ios/AirGoogleMaps/AIRGoogleMapOverlay.h +0 -1
  15. package/ios/AirGoogleMaps/AIRGoogleMapPolygon.h +5 -4
  16. package/ios/AirGoogleMaps/AIRGoogleMapPolygon.m +32 -2
  17. package/ios/AirGoogleMaps/AIRGoogleMapPolygonManager.m +3 -3
  18. package/ios/AirGoogleMaps/AIRGoogleMapPolyline.h +3 -2
  19. package/ios/AirGoogleMaps/AIRGoogleMapPolyline.m +2 -3
  20. package/ios/AirGoogleMaps/AIRGoogleMapPolylineManager.m +2 -2
  21. package/ios/AirGoogleMaps/AIRGoogleMapWMSTile.h +1 -1
  22. package/ios/AirGoogleMaps/AIRGoogleMapWMSTile.m +2 -2
  23. package/ios/AirGoogleMaps/RCTConvert+GMSMapViewType.h +3 -0
  24. package/ios/AirGoogleMaps/RCTConvert+GMSMapViewType.m +18 -0
  25. package/ios/AirGoogleMaps/RNMapsGoogleMapView.h +26 -0
  26. package/ios/AirGoogleMaps/RNMapsGoogleMapView.mm +599 -0
  27. package/ios/AirGoogleMaps/RNMapsGoogleMapViewManager.mm +25 -0
  28. package/ios/AirGoogleMaps/RNMapsGooglePolygonView.h +26 -0
  29. package/ios/AirGoogleMaps/RNMapsGooglePolygonView.mm +217 -0
  30. package/ios/AirGoogleMaps/RNMapsGooglePolygonViewManager.mm +25 -0
  31. package/ios/AirMaps/AIRMap.h +8 -5
  32. package/ios/AirMaps/AIRMap.m +284 -141
  33. package/ios/AirMaps/AIRMapManager.m +12 -21
  34. package/ios/AirMaps/AIRMapMarker.h +1 -0
  35. package/ios/AirMaps/AIRMapMarker.m +165 -103
  36. package/ios/AirMaps/Callout/SMCalloutView.m +1 -1
  37. package/ios/AirMaps/RCTConvert+AirMap.h +4 -0
  38. package/ios/AirMaps/RCTConvert+AirMap.m +2 -0
  39. package/ios/AirMaps/RNMapsAirModule.h +3 -0
  40. package/ios/AirMaps/RNMapsAirModule.mm +42 -172
  41. package/ios/AirMaps/RNMapsAirModuleDelegate.h +24 -0
  42. package/ios/AirMaps/RNMapsHostVewDelegate.h +17 -0
  43. package/ios/AirMaps/RNMapsMapView.h +6 -3
  44. package/ios/AirMaps/RNMapsMapView.mm +341 -334
  45. package/ios/AirMaps/RNMapsMarkerView.h +24 -0
  46. package/ios/AirMaps/RNMapsMarkerView.mm +422 -0
  47. package/ios/AirMaps/RNMapsMarkerViewManager.mm +21 -0
  48. package/ios/AirMaps/UIView +AirMap.m +20 -0
  49. package/ios/AirMaps/UIView+AirMap.h +11 -0
  50. package/lib/MapMarker.d.ts +15 -2
  51. package/lib/MapMarker.js +53 -9
  52. package/lib/MapMarkerNativeComponent.js +0 -2
  53. package/lib/MapOverlay.d.ts +1 -1
  54. package/lib/MapView.d.ts +5 -22
  55. package/lib/MapView.js +34 -21
  56. package/lib/{FabricMapView.d.ts → createFabricMap.d.ts} +7 -6
  57. package/lib/createFabricMap.js +175 -0
  58. package/lib/decorateMapComponent.js +18 -0
  59. package/lib/specs/NativeAirMapsModule.d.ts +2 -2
  60. package/lib/specs/NativeComponentGoogleMapView.d.ts +713 -0
  61. package/lib/specs/NativeComponentGoogleMapView.js +21 -0
  62. package/lib/specs/NativeComponentGooglePolygon.d.ts +75 -0
  63. package/lib/specs/NativeComponentGooglePolygon.js +9 -0
  64. package/lib/specs/NativeComponentMapView.d.ts +21 -45
  65. package/lib/specs/NativeComponentMarker.d.ts +258 -0
  66. package/lib/specs/NativeComponentMarker.js +21 -0
  67. package/package.json +7 -7
  68. package/react-native-maps.podspec +1 -1
  69. package/lib/FabricMapView.js +0 -175
@@ -19,14 +19,9 @@
19
19
  #import <React/UIView+React.h>
20
20
  #import "RCTConvert+GMSMapViewType.h"
21
21
  #import "AIRGoogleMap.h"
22
- #import "AIRMapMarker.h"
23
- #import "AIRMapPolyline.h"
24
- #import "AIRMapPolygon.h"
25
- #import "AIRMapCircle.h"
26
- #import "SMCalloutView.h"
27
22
  #import "AIRGoogleMapMarker.h"
28
- #import "RCTConvert+AirMap.h"
29
-
23
+ #import "AIRGoogleMapCoordinate.h"
24
+ #import "RCTConvert+GMSMapViewType.h"
30
25
  #import <MapKit/MapKit.h>
31
26
  #import <QuartzCore/QuartzCore.h>
32
27
 
@@ -45,26 +40,22 @@ RCT_EXPORT_MODULE()
45
40
 
46
41
  - (UIView *)view
47
42
  {
48
- NSString* googleMapId = nil;
49
- BOOL zoomTapEnabled = YES;
50
- UIColor* backgroundColor = nil;
51
- GMSCameraPosition* camera = nil;
52
43
 
53
44
  if (self.initialProps){
54
45
  if (self.initialProps[@"googleMapId"]){
55
- googleMapId = self.initialProps[@"googleMapId"];
46
+ _googleMapId = self.initialProps[@"googleMapId"];
56
47
  }
57
48
  if (self.initialProps[@"zoomTapEnabled"]){
58
- zoomTapEnabled = self.initialProps[@"zoomTapEnabled"];
49
+ _zoomTapEnabled = self.initialProps[@"zoomTapEnabled"];
59
50
  }
60
51
  if (self.initialProps[@"loadingBackgroundColor"]){
61
- backgroundColor = [RCTConvert UIColor:self.initialProps[@"loadingBackgroundColor"]];
52
+ _backgroundColor = [RCTConvert UIColor:self.initialProps[@"loadingBackgroundColor"]];
62
53
  }
63
54
  if (self.initialProps[@"initialCamera"]){
64
- camera = [RCTConvert GMSCameraPositionWithDefaults:self.initialProps[@"initialCamera"] existingCamera:nil];
55
+ _camera = [RCTConvert GMSCameraPositionWithDefaults:self.initialProps[@"initialCamera"] existingCamera:nil];
65
56
  }
66
57
  }
67
- AIRGoogleMap *map = [[AIRGoogleMap alloc] initWithMapId:googleMapId initialCamera:camera backgroundColor:backgroundColor andZoomTapEnabled:zoomTapEnabled];
58
+ AIRGoogleMap *map = [[AIRGoogleMap alloc] initWithMapId:self.googleMapId initialCamera:self.camera backgroundColor:self.backgroundColor andZoomTapEnabled:self.zoomTapEnabled];
68
59
  map.bridge = self.bridge;
69
60
  map.delegate = self;
70
61
  map.isAccessibilityElement = NO;
@@ -217,32 +208,8 @@ RCT_EXPORT_METHOD(fitToElements:(nonnull NSNumber *)reactTag
217
208
  if (![view isKindOfClass:[AIRGoogleMap class]]) {
218
209
  RCTLogError(@"Invalid view returned from registry, expecting AIRGoogleMap, got: %@", view);
219
210
  } else {
220
- AIRGoogleMap *mapView = (AIRGoogleMap *)view;
221
-
222
- CLLocationCoordinate2D myLocation = ((AIRGoogleMapMarker *)(mapView.markers.firstObject)).realMarker.position;
223
- GMSCoordinateBounds *bounds = [[GMSCoordinateBounds alloc] initWithCoordinate:myLocation coordinate:myLocation];
224
-
225
- for (AIRGoogleMapMarker *marker in mapView.markers)
226
- bounds = [bounds includingCoordinate:marker.realMarker.position];
227
-
228
- GMSCameraUpdate* cameraUpdate;
229
-
230
- if ([edgePadding count] != 0) {
231
- // Set Map viewport
232
- CGFloat top = [RCTConvert CGFloat:edgePadding[@"top"]];
233
- CGFloat right = [RCTConvert CGFloat:edgePadding[@"right"]];
234
- CGFloat bottom = [RCTConvert CGFloat:edgePadding[@"bottom"]];
235
- CGFloat left = [RCTConvert CGFloat:edgePadding[@"left"]];
236
-
237
- cameraUpdate = [GMSCameraUpdate fitBounds:bounds withEdgeInsets:UIEdgeInsetsMake(top, left, bottom, right)];
238
- } else {
239
- cameraUpdate = [GMSCameraUpdate fitBounds:bounds withPadding:55.0f];
240
- }
241
- if (animated) {
242
- [mapView animateWithCameraUpdate: cameraUpdate];
243
- } else {
244
- [mapView moveCamera: cameraUpdate];
245
- }
211
+ AIRGoogleMap *mapView = (AIRGoogleMap *)view;
212
+ [mapView fitToElementsWithEdgePadding:edgePadding animated:animated];
246
213
  }
247
214
  }];
248
215
  }
@@ -257,40 +224,14 @@ RCT_EXPORT_METHOD(fitToSuppliedMarkers:(nonnull NSNumber *)reactTag
257
224
  if (![view isKindOfClass:[AIRGoogleMap class]]) {
258
225
  RCTLogError(@"Invalid view returned from registry, expecting AIRGoogleMap, got: %@", view);
259
226
  } else {
260
- AIRGoogleMap *mapView = (AIRGoogleMap *)view;
261
-
262
- NSPredicate *filterMarkers = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings) {
263
- AIRGoogleMapMarker *marker = (AIRGoogleMapMarker *)evaluatedObject;
264
- return [marker isKindOfClass:[AIRGoogleMapMarker class]] && [markers containsObject:marker.identifier];
265
- }];
266
-
267
- NSArray *filteredMarkers = [mapView.markers filteredArrayUsingPredicate:filterMarkers];
268
-
269
- CLLocationCoordinate2D myLocation = ((AIRGoogleMapMarker *)(filteredMarkers.firstObject)).realMarker.position;
270
- GMSCoordinateBounds *bounds = [[GMSCoordinateBounds alloc] initWithCoordinate:myLocation coordinate:myLocation];
271
-
272
- for (AIRGoogleMapMarker *marker in filteredMarkers)
273
- bounds = [bounds includingCoordinate:marker.realMarker.position];
274
-
275
- // Set Map viewport
276
- CGFloat top = [RCTConvert CGFloat:edgePadding[@"top"]];
277
- CGFloat right = [RCTConvert CGFloat:edgePadding[@"right"]];
278
- CGFloat bottom = [RCTConvert CGFloat:edgePadding[@"bottom"]];
279
- CGFloat left = [RCTConvert CGFloat:edgePadding[@"left"]];
280
-
281
- GMSCameraUpdate* cameraUpdate = [GMSCameraUpdate fitBounds:bounds withEdgeInsets:UIEdgeInsetsMake(top, left, bottom, right)];
282
- if (animated) {
283
- [mapView animateWithCameraUpdate:cameraUpdate
284
- ];
285
- } else {
286
- [mapView moveCamera: cameraUpdate];
287
- }
227
+ AIRGoogleMap *mapView = (AIRGoogleMap *)view;
228
+ [mapView fitToSuppliedMarkers:markers withEdgePadding:edgePadding animated:animated];
288
229
  }
289
230
  }];
290
231
  }
291
232
 
292
233
  RCT_EXPORT_METHOD(fitToCoordinates:(nonnull NSNumber *)reactTag
293
- coordinates:(nonnull NSArray<AIRMapCoordinate *> *)coordinates
234
+ coordinates:(nonnull NSArray<AIRGoogleMapCoordinate *> *)coordinates
294
235
  edgePadding:(nonnull NSDictionary *)edgePadding
295
236
  animated:(BOOL)animated)
296
237
  {
@@ -300,26 +241,7 @@ RCT_EXPORT_METHOD(fitToCoordinates:(nonnull NSNumber *)reactTag
300
241
  RCTLogError(@"Invalid view returned from registry, expecting AIRGoogleMap, got: %@", view);
301
242
  } else {
302
243
  AIRGoogleMap *mapView = (AIRGoogleMap *)view;
303
-
304
- CLLocationCoordinate2D myLocation = coordinates.firstObject.coordinate;
305
- GMSCoordinateBounds *bounds = [[GMSCoordinateBounds alloc] initWithCoordinate:myLocation coordinate:myLocation];
306
-
307
- for (AIRMapCoordinate *coordinate in coordinates)
308
- bounds = [bounds includingCoordinate:coordinate.coordinate];
309
-
310
- // Set Map viewport
311
- CGFloat top = [RCTConvert CGFloat:edgePadding[@"top"]];
312
- CGFloat right = [RCTConvert CGFloat:edgePadding[@"right"]];
313
- CGFloat bottom = [RCTConvert CGFloat:edgePadding[@"bottom"]];
314
- CGFloat left = [RCTConvert CGFloat:edgePadding[@"left"]];
315
-
316
- GMSCameraUpdate *cameraUpdate = [GMSCameraUpdate fitBounds:bounds withEdgeInsets:UIEdgeInsetsMake(top, left, bottom, right)];
317
-
318
- if (animated) {
319
- [mapView animateWithCameraUpdate: cameraUpdate];
320
- } else {
321
- [mapView moveCamera: cameraUpdate];
322
- }
244
+ [mapView fitToCoordinates:coordinates withEdgePadding:edgePadding animated:animated];
323
245
  }
324
246
  }];
325
247
  }
@@ -331,7 +253,7 @@ RCT_EXPORT_METHOD(takeSnapshot:(nonnull NSNumber *)reactTag
331
253
  format:(nonnull NSString *)format
332
254
  quality:(nonnull NSNumber *)quality
333
255
  result:(nonnull NSString *)result
334
- withCallback:(RCTResponseSenderBlock)callback)
256
+ withCallback:(RCTPromiseResolveBlock)callback)
335
257
  {
336
258
  NSTimeInterval timeStamp = [[NSDate date] timeIntervalSince1970];
337
259
  NSString *pathComponent = [NSString stringWithFormat:@"Documents/snapshot-%.20lf.%@", timeStamp, format];
@@ -342,7 +264,19 @@ RCT_EXPORT_METHOD(takeSnapshot:(nonnull NSNumber *)reactTag
342
264
  if (![view isKindOfClass:[AIRGoogleMap class]]) {
343
265
  RCTLogError(@"Invalid view returned from registry, expecting AIRMap, got: %@", view);
344
266
  } else {
345
- AIRGoogleMap *mapView = (AIRGoogleMap *)view;
267
+ AIRGoogleMap *mapView = (AIRGoogleMap *)view;
268
+ NSMutableDictionary* config = [NSMutableDictionary new];
269
+
270
+ [mapView takeSnapshotWithConfig:config success:callback error:^(NSString *code, NSString *message, NSError *error) {
271
+ callback(@[error]);
272
+ }];
273
+
274
+ [config setObject:width forKey:@"width"];
275
+ [config setObject:height forKey:@"height"];
276
+ [config setObject:format forKey:@"format"];
277
+ [config setObject:quality forKey:@"quality"];
278
+ [config setObject:result forKey:@"result"];
279
+ [config setObject:filePath forKey:@"filePath"];
346
280
 
347
281
  // TODO: currently we are ignoring width, height, region
348
282
 
@@ -388,13 +322,7 @@ RCT_EXPORT_METHOD(pointForCoordinate:(nonnull NSNumber *)reactTag
388
322
  RCTLogError(@"Invalid view returned from registry, expecting AIRMap, got: %@", view);
389
323
  } else {
390
324
  AIRGoogleMap *mapView = (AIRGoogleMap *)view;
391
-
392
- CGPoint touchPoint = [mapView.projection pointForCoordinate:coord];
393
-
394
- resolve(@{
395
- @"x": @(touchPoint.x),
396
- @"y": @(touchPoint.y),
397
- });
325
+ resolve([mapView getPointForCoordinates:coord]);
398
326
  }
399
327
  }];
400
328
  }
@@ -415,13 +343,7 @@ RCT_EXPORT_METHOD(coordinateForPoint:(nonnull NSNumber *)reactTag
415
343
  RCTLogError(@"Invalid view returned from registry, expecting AIRMap, got: %@", view);
416
344
  } else {
417
345
  AIRGoogleMap *mapView = (AIRGoogleMap *)view;
418
-
419
- CLLocationCoordinate2D coordinate = [mapView.projection coordinateForPoint:pt];
420
-
421
- resolve(@{
422
- @"latitude": @(coordinate.latitude),
423
- @"longitude": @(coordinate.longitude),
424
- });
346
+ resolve([view getCoordinatesForPoint:pt]);
425
347
  }
426
348
  }];
427
349
  }
@@ -451,18 +373,7 @@ RCT_EXPORT_METHOD(getMapBoundaries:(nonnull NSNumber *)reactTag
451
373
  if (![view isKindOfClass:[AIRGoogleMap class]]) {
452
374
  RCTLogError(@"Invalid view returned from registry, expecting AIRGoogleMap, got: %@", view);
453
375
  } else {
454
- NSArray *boundingBox = [view getMapBoundaries];
455
-
456
- resolve(@{
457
- @"northEast" : @{
458
- @"longitude" : boundingBox[0][0],
459
- @"latitude" : boundingBox[0][1]
460
- },
461
- @"southWest" : @{
462
- @"longitude" : boundingBox[1][0],
463
- @"latitude" : boundingBox[1][1]
464
- }
465
- });
376
+ resolve([view getMapBoundaries]);
466
377
  }
467
378
  }];
468
379
  }
@@ -53,6 +53,8 @@
53
53
  - (void)didDragMarker:(AIRGMSMarker *)marker;
54
54
  - (id)makeEventData;
55
55
  - (id)makeEventData:(NSString *)action;
56
+ - (UIView *) iconView;
57
+ - (void) didInsertInMap:(AIRGoogleMap *) map;
56
58
  @end
57
59
 
58
60
  #endif