react-native-maps 1.21.0-alpha.5 → 1.21.0-alpha.50

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 (103) hide show
  1. package/android/build.gradle +30 -6
  2. package/android/generated/java/com/facebook/fbreact/specs/NativeAirMapsModuleSpec.java +63 -0
  3. package/android/generated/jni/CMakeLists.txt +36 -0
  4. package/android/generated/jni/RNMapsSpecs-generated.cpp +68 -0
  5. package/android/generated/jni/RNMapsSpecs.h +31 -0
  6. package/android/generated/jni/react/renderer/components/RNMapsSpecs/ComponentDescriptors.cpp +25 -0
  7. package/android/generated/jni/react/renderer/components/RNMapsSpecs/ComponentDescriptors.h +27 -0
  8. package/android/generated/jni/react/renderer/components/RNMapsSpecs/EventEmitters.cpp +896 -0
  9. package/android/generated/jni/react/renderer/components/RNMapsSpecs/EventEmitters.h +765 -0
  10. package/android/generated/jni/react/renderer/components/RNMapsSpecs/Props.cpp +146 -0
  11. package/android/generated/jni/react/renderer/components/RNMapsSpecs/Props.h +1047 -0
  12. package/android/generated/jni/react/renderer/components/RNMapsSpecs/RNMapsSpecsJSI-generated.cpp +74 -0
  13. package/android/generated/jni/react/renderer/components/RNMapsSpecs/RNMapsSpecsJSI.h +264 -0
  14. package/android/generated/jni/react/renderer/components/RNMapsSpecs/ShadowNodes.cpp +20 -0
  15. package/android/generated/jni/react/renderer/components/RNMapsSpecs/ShadowNodes.h +65 -0
  16. package/android/generated/jni/react/renderer/components/RNMapsSpecs/States.cpp +16 -0
  17. package/android/generated/jni/react/renderer/components/RNMapsSpecs/States.h +65 -0
  18. package/android/src/main/java/com/rnmaps/fabric/NativeAirMapsModule.java +2 -1
  19. package/android/src/main/java/com/rnmaps/maps/MapAirModulePackage.java +1 -1
  20. package/ios/AirGoogleMaps/AIRGoogleMap.h +8 -2
  21. package/ios/AirGoogleMaps/AIRGoogleMap.m +243 -55
  22. package/ios/AirGoogleMaps/AIRGoogleMapCircle.h +0 -1
  23. package/ios/AirGoogleMaps/AIRGoogleMapCircle.m +23 -11
  24. package/ios/AirGoogleMaps/AIRGoogleMapCoordinate.h +13 -0
  25. package/ios/AirGoogleMaps/AIRGoogleMapCoordinate.m +10 -0
  26. package/ios/AirGoogleMaps/AIRGoogleMapManager.h +7 -0
  27. package/ios/AirGoogleMaps/AIRGoogleMapManager.m +30 -119
  28. package/ios/AirGoogleMaps/AIRGoogleMapMarker.h +2 -0
  29. package/ios/AirGoogleMaps/AIRGoogleMapMarker.m +347 -243
  30. package/ios/AirGoogleMaps/AIRGoogleMapMarkerManager.m +0 -1
  31. package/ios/AirGoogleMaps/AIRGoogleMapOverlay.h +0 -1
  32. package/ios/AirGoogleMaps/AIRGoogleMapPolygon.h +5 -4
  33. package/ios/AirGoogleMaps/AIRGoogleMapPolygon.m +32 -2
  34. package/ios/AirGoogleMaps/AIRGoogleMapPolygonManager.m +3 -3
  35. package/ios/AirGoogleMaps/AIRGoogleMapPolyline.h +3 -2
  36. package/ios/AirGoogleMaps/AIRGoogleMapPolyline.m +2 -3
  37. package/ios/AirGoogleMaps/AIRGoogleMapPolylineManager.m +2 -2
  38. package/ios/AirGoogleMaps/AIRGoogleMapWMSTile.h +1 -1
  39. package/ios/AirGoogleMaps/AIRGoogleMapWMSTile.m +2 -2
  40. package/ios/AirGoogleMaps/RCTConvert+GMSMapViewType.h +3 -0
  41. package/ios/AirGoogleMaps/RCTConvert+GMSMapViewType.m +18 -0
  42. package/ios/AirGoogleMaps/RNMapsGoogleMapView.h +26 -0
  43. package/ios/AirGoogleMaps/RNMapsGoogleMapView.mm +629 -0
  44. package/ios/AirGoogleMaps/RNMapsGoogleMapViewManager.mm +25 -0
  45. package/ios/AirGoogleMaps/RNMapsGooglePolygonView.h +26 -0
  46. package/ios/AirGoogleMaps/RNMapsGooglePolygonView.mm +217 -0
  47. package/ios/AirGoogleMaps/RNMapsGooglePolygonViewManager.mm +25 -0
  48. package/ios/AirMaps/AIRMap.h +8 -5
  49. package/ios/AirMaps/AIRMap.m +292 -141
  50. package/ios/AirMaps/AIRMapManager.m +12 -21
  51. package/ios/AirMaps/AIRMapMarker.h +1 -0
  52. package/ios/AirMaps/AIRMapMarker.m +165 -103
  53. package/ios/AirMaps/Callout/SMCalloutView.m +1 -1
  54. package/ios/AirMaps/RCTConvert+AirMap.h +4 -0
  55. package/ios/AirMaps/RCTConvert+AirMap.m +2 -0
  56. package/ios/AirMaps/RNMapsAirModule.h +4 -1
  57. package/ios/AirMaps/RNMapsAirModule.mm +42 -172
  58. package/ios/AirMaps/RNMapsAirModuleDelegate.h +24 -0
  59. package/ios/AirMaps/RNMapsHostVewDelegate.h +17 -0
  60. package/ios/AirMaps/RNMapsMapView.h +6 -3
  61. package/ios/AirMaps/RNMapsMapView.mm +346 -332
  62. package/ios/AirMaps/RNMapsMarkerView.h +24 -0
  63. package/ios/AirMaps/RNMapsMarkerView.mm +430 -0
  64. package/ios/AirMaps/RNMapsMarkerViewManager.mm +21 -0
  65. package/ios/AirMaps/UIView +AirMap.m +20 -0
  66. package/ios/AirMaps/UIView+AirMap.h +11 -0
  67. package/ios/AirMaps.xcodeproj/project.pbxproj +60 -0
  68. package/ios/generated/RNMapsSpecs/ComponentDescriptors.cpp +25 -0
  69. package/ios/generated/RNMapsSpecs/ComponentDescriptors.h +27 -0
  70. package/ios/generated/RNMapsSpecs/EventEmitters.cpp +896 -0
  71. package/ios/generated/RNMapsSpecs/EventEmitters.h +765 -0
  72. package/ios/generated/RNMapsSpecs/Props.cpp +146 -0
  73. package/ios/generated/RNMapsSpecs/Props.h +1047 -0
  74. package/ios/generated/RNMapsSpecs/RCTComponentViewHelpers.h +549 -0
  75. package/ios/generated/RNMapsSpecs/RNMapsSpecs-generated.mm +92 -0
  76. package/ios/generated/RNMapsSpecs/RNMapsSpecs.h +134 -0
  77. package/ios/generated/RNMapsSpecs/ShadowNodes.cpp +20 -0
  78. package/ios/generated/RNMapsSpecs/ShadowNodes.h +65 -0
  79. package/ios/generated/RNMapsSpecs/States.cpp +16 -0
  80. package/ios/generated/RNMapsSpecs/States.h +65 -0
  81. package/ios/generated/RNMapsSpecsJSI-generated.cpp +74 -0
  82. package/ios/generated/RNMapsSpecsJSI.h +264 -0
  83. package/lib/MapMarker.d.ts +15 -2
  84. package/lib/MapMarker.js +53 -9
  85. package/lib/MapMarkerNativeComponent.js +0 -2
  86. package/lib/MapOverlay.d.ts +1 -1
  87. package/lib/MapOverlay.js +2 -8
  88. package/lib/MapView.d.ts +5 -22
  89. package/lib/MapView.js +34 -21
  90. package/lib/{FabricMapView.d.ts → createFabricMap.d.ts} +7 -6
  91. package/lib/createFabricMap.js +175 -0
  92. package/lib/decorateMapComponent.js +18 -0
  93. package/lib/specs/NativeAirMapsModule.d.ts +2 -2
  94. package/lib/specs/NativeComponentGoogleMapView.d.ts +713 -0
  95. package/lib/specs/NativeComponentGoogleMapView.js +21 -0
  96. package/lib/specs/NativeComponentGooglePolygon.d.ts +75 -0
  97. package/lib/specs/NativeComponentGooglePolygon.js +9 -0
  98. package/lib/specs/NativeComponentMapView.d.ts +21 -45
  99. package/lib/specs/NativeComponentMarker.d.ts +258 -0
  100. package/lib/specs/NativeComponentMarker.js +21 -0
  101. package/package.json +12 -6
  102. package/react-native-maps.podspec +2 -1
  103. package/lib/FabricMapView.js +0 -175
@@ -17,11 +17,12 @@
17
17
  #import "AIRGoogleMapUrlTile.h"
18
18
  #import "AIRGoogleMapWMSTile.h"
19
19
  #import "AIRGoogleMapOverlay.h"
20
+ #import "AIRGoogleMapCoordinate.h"
20
21
  #import <GoogleMaps/GoogleMaps.h>
21
22
  #import <MapKit/MapKit.h>
22
23
  #import <React/UIView+React.h>
23
24
  #import <React/RCTBridge.h>
24
- #import "RCTConvert+AirMap.h"
25
+ #import <React/RCTConvert.h>
25
26
  #import <objc/runtime.h>
26
27
 
27
28
  #ifdef HAVE_GOOGLE_MAPS_UTILS
@@ -68,6 +69,7 @@ id regionAsJSON(MKCoordinateRegion region) {
68
69
  BOOL _didPrepareMap;
69
70
  BOOL _didCallOnMapReady;
70
71
  BOOL _zoomTapEnabled;
72
+ BOOL _isAnimating;
71
73
  NSString* _googleMapId;
72
74
  }
73
75
 
@@ -86,7 +88,7 @@ id regionAsJSON(MKCoordinateRegion region) {
86
88
  [options setCamera:camera];
87
89
  }
88
90
  self = [super initWithOptions:options];
89
-
91
+
90
92
  if (self) {
91
93
  _reactSubviews = [NSMutableArray new];
92
94
  _markers = [NSMutableArray array];
@@ -145,6 +147,92 @@ id regionAsJSON(MKCoordinateRegion region) {
145
147
  };
146
148
  }
147
149
 
150
+ - (BOOL) isReady {
151
+ return _didPrepareMap;
152
+ }
153
+
154
+ -(void) fitToCoordinates:(NSArray<AIRGoogleMapCoordinate *> *) coordinates withEdgePadding:(NSDictionary*) edgePadding animated:(BOOL)animated
155
+ {
156
+ CLLocationCoordinate2D myLocation = coordinates.firstObject.coordinate;
157
+ GMSCoordinateBounds *bounds = [[GMSCoordinateBounds alloc] initWithCoordinate:myLocation coordinate:myLocation];
158
+
159
+ for (AIRGoogleMapCoordinate *coordinate in coordinates)
160
+ bounds = [bounds includingCoordinate:coordinate.coordinate];
161
+
162
+ // Set Map viewport
163
+ CGFloat top = [RCTConvert CGFloat:edgePadding[@"top"]];
164
+ CGFloat right = [RCTConvert CGFloat:edgePadding[@"right"]];
165
+ CGFloat bottom = [RCTConvert CGFloat:edgePadding[@"bottom"]];
166
+ CGFloat left = [RCTConvert CGFloat:edgePadding[@"left"]];
167
+
168
+ GMSCameraUpdate *cameraUpdate = [GMSCameraUpdate fitBounds:bounds withEdgeInsets:UIEdgeInsetsMake(top, left, bottom, right)];
169
+
170
+ if (animated) {
171
+ [self animateWithCameraUpdate: cameraUpdate];
172
+ } else {
173
+ [self moveCamera: cameraUpdate];
174
+ }
175
+ }
176
+
177
+ -(void) fitToElementsWithEdgePadding:(nonnull NSDictionary *)edgePadding
178
+ animated:(BOOL)animated
179
+ {
180
+ CLLocationCoordinate2D myLocation = ((AIRGoogleMapMarker *)(self.markers.firstObject)).realMarker.position;
181
+ GMSCoordinateBounds *bounds = [[GMSCoordinateBounds alloc] initWithCoordinate:myLocation coordinate:myLocation];
182
+
183
+ for (AIRGoogleMapMarker *marker in self.markers)
184
+ bounds = [bounds includingCoordinate:marker.realMarker.position];
185
+
186
+ GMSCameraUpdate* cameraUpdate;
187
+
188
+ if ([edgePadding count] != 0) {
189
+ // Set Map viewport
190
+ CGFloat top = [RCTConvert CGFloat:edgePadding[@"top"]];
191
+ CGFloat right = [RCTConvert CGFloat:edgePadding[@"right"]];
192
+ CGFloat bottom = [RCTConvert CGFloat:edgePadding[@"bottom"]];
193
+ CGFloat left = [RCTConvert CGFloat:edgePadding[@"left"]];
194
+
195
+ cameraUpdate = [GMSCameraUpdate fitBounds:bounds withEdgeInsets:UIEdgeInsetsMake(top, left, bottom, right)];
196
+ } else {
197
+ cameraUpdate = [GMSCameraUpdate fitBounds:bounds withPadding:55.0f];
198
+ }
199
+ if (animated) {
200
+ [self animateWithCameraUpdate: cameraUpdate];
201
+ } else {
202
+ [self moveCamera: cameraUpdate];
203
+ }
204
+ }
205
+
206
+ - (void) fitToSuppliedMarkers:(NSArray*) markers withEdgePadding:(NSDictionary*) edgePadding animated:(BOOL)animated
207
+ {
208
+ NSPredicate *filterMarkers = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings) {
209
+ AIRGoogleMapMarker *marker = (AIRGoogleMapMarker *)evaluatedObject;
210
+ return [marker isKindOfClass:[AIRGoogleMapMarker class]] && [markers containsObject:marker.identifier];
211
+ }];
212
+
213
+ NSArray *filteredMarkers = [self.markers filteredArrayUsingPredicate:filterMarkers];
214
+
215
+ CLLocationCoordinate2D myLocation = ((AIRGoogleMapMarker *)(filteredMarkers.firstObject)).realMarker.position;
216
+ GMSCoordinateBounds *bounds = [[GMSCoordinateBounds alloc] initWithCoordinate:myLocation coordinate:myLocation];
217
+
218
+ for (AIRGoogleMapMarker *marker in filteredMarkers)
219
+ bounds = [bounds includingCoordinate:marker.realMarker.position];
220
+
221
+ // Set Map viewport
222
+ CGFloat top = [RCTConvert CGFloat:edgePadding[@"top"]];
223
+ CGFloat right = [RCTConvert CGFloat:edgePadding[@"right"]];
224
+ CGFloat bottom = [RCTConvert CGFloat:edgePadding[@"bottom"]];
225
+ CGFloat left = [RCTConvert CGFloat:edgePadding[@"left"]];
226
+
227
+ GMSCameraUpdate* cameraUpdate = [GMSCameraUpdate fitBounds:bounds withEdgeInsets:UIEdgeInsetsMake(top, left, bottom, right)];
228
+ if (animated) {
229
+ [self animateWithCameraUpdate:cameraUpdate
230
+ ];
231
+ } else {
232
+ [self moveCamera: cameraUpdate];
233
+ }
234
+ }
235
+
148
236
  #pragma clang diagnostic push
149
237
  #pragma clang diagnostic ignored "-Wobjc-missing-super-calls"
150
238
  - (void)insertReactSubview:(id<RCTComponent>)subview atIndex:(NSInteger)atIndex {
@@ -152,12 +240,17 @@ id regionAsJSON(MKCoordinateRegion region) {
152
240
  // This is where we intercept them and do the appropriate underlying mapview action.
153
241
  if ([subview isKindOfClass:[AIRGoogleMapMarker class]]) {
154
242
  AIRGoogleMapMarker *marker = (AIRGoogleMapMarker*)subview;
155
- marker.realMarker.map = self;
243
+ [marker didInsertInMap:self];
156
244
  [self.markers addObject:marker];
157
245
  } else if ([subview isKindOfClass:[AIRGoogleMapPolygon class]]) {
158
246
  AIRGoogleMapPolygon *polygon = (AIRGoogleMapPolygon*)subview;
159
- polygon.polygon.map = self;
247
+ [polygon didInsertInMap:self];
160
248
  [self.polygons addObject:polygon];
249
+
250
+ } else if ([NSStringFromClass([subview class]) isEqualToString:@"RNMapsGooglePolygonView"]){
251
+ // RNMapsGooglePolygonView *polygon = (RNMapsGooglePolygonView*)subview;
252
+ // [polygon didInsertInMap:self];
253
+ [self.polygons addObject:subview];
161
254
  } else if ([subview isKindOfClass:[AIRGoogleMapPolyline class]]) {
162
255
  AIRGoogleMapPolyline *polyline = (AIRGoogleMapPolyline*)subview;
163
256
  polyline.polyline.map = self;
@@ -202,7 +295,9 @@ id regionAsJSON(MKCoordinateRegion region) {
202
295
  AIRGoogleMapMarker *marker = (AIRGoogleMapMarker*)subview;
203
296
  marker.realMarker.map = nil;
204
297
  [self.markers removeObject:marker];
205
- } else if ([subview isKindOfClass:[AIRGoogleMapPolygon class]]) {
298
+ } else if ([NSStringFromClass([subview class]) isEqualToString:@"RNMapsGooglePolygonView"]) {
299
+ [self.polygons removeObject:subview];
300
+ } else if ([subview isKindOfClass:[AIRGoogleMapPolygon class]]) {
206
301
  AIRGoogleMapPolygon *polygon = (AIRGoogleMapPolygon*)subview;
207
302
  polygon.polygon.map = nil;
208
303
  [self.polygons removeObject:polygon];
@@ -267,6 +362,19 @@ id regionAsJSON(MKCoordinateRegion region) {
267
362
  ];
268
363
  }
269
364
 
365
+ - (NSDictionary *) getCameraDic {
366
+ GMSCameraPosition *camera = [self camera];
367
+ return @{
368
+ @"center": @{
369
+ @"latitude": @(camera.target.latitude),
370
+ @"longitude": @(camera.target.longitude),
371
+ },
372
+ @"pitch": @(camera.viewingAngle),
373
+ @"heading": @(camera.bearing),
374
+ @"zoom": @(camera.zoom),
375
+ };
376
+ }
377
+
270
378
  - (void)layoutSubviews {
271
379
  [super layoutSubviews];
272
380
  if(_didLayoutSubviews) return;
@@ -303,7 +411,7 @@ id regionAsJSON(MKCoordinateRegion region) {
303
411
  }
304
412
 
305
413
  - (void)setRegion:(MKCoordinateRegion)region {
306
- // TODO: The JS component is repeatedly setting region unnecessarily. We might want to deal with that in here.
414
+ if (_isAnimating || !CLLocationCoordinate2DIsValid(region.center)) return;
307
415
  _region = region;
308
416
  if(_didLayoutSubviews) {
309
417
  self.camera = [AIRGoogleMap makeGMSCameraPositionFromMap:self andMKCoordinateRegion:region];
@@ -323,6 +431,7 @@ id regionAsJSON(MKCoordinateRegion region) {
323
431
  }
324
432
 
325
433
  - (void)setCameraProp:(GMSCameraPosition*)camera {
434
+ if (_isAnimating || !CLLocationCoordinate2DIsValid([camera target])) return;
326
435
  _initialCamera = camera;
327
436
  if(_didLayoutSubviews) {
328
437
  self.camera = camera;
@@ -404,6 +513,7 @@ id regionAsJSON(MKCoordinateRegion region) {
404
513
  }
405
514
 
406
515
  - (void)willMove:(BOOL)gesture {
516
+ _isAnimating = YES;
407
517
  id event = @{@"isGesture": [NSNumber numberWithBool:gesture]};
408
518
  if (self.onRegionChangeStart) self.onRegionChangeStart(event);
409
519
  }
@@ -437,6 +547,7 @@ id regionAsJSON(MKCoordinateRegion region) {
437
547
  @"isGesture": [NSNumber numberWithBool:isGesture],
438
548
  };
439
549
  if (self.onChange) self.onChange(event); // complete
550
+ _isAnimating = NO;
440
551
  }
441
552
 
442
553
  - (void)setMapPadding:(UIEdgeInsets)mapPadding {
@@ -579,11 +690,11 @@ id regionAsJSON(MKCoordinateRegion region) {
579
690
  return self.settings.myLocationButton;
580
691
  }
581
692
 
582
- - (void)setMinZoomLevel:(CGFloat)minZoomLevel {
693
+ - (void)setMinZoom:(CGFloat)minZoomLevel {
583
694
  [self setMinZoom:minZoomLevel maxZoom:self.maxZoom ];
584
695
  }
585
696
 
586
- - (void)setMaxZoomLevel:(CGFloat)maxZoomLevel {
697
+ - (void)setMaxZoom:(CGFloat)maxZoomLevel {
587
698
  [self setMinZoom:self.minZoom maxZoom:maxZoomLevel ];
588
699
  }
589
700
 
@@ -610,7 +721,7 @@ id regionAsJSON(MKCoordinateRegion region) {
610
721
  AIRGMSMarker *airMarker = (AIRGMSMarker *) self.selectedMarker;
611
722
  AIRGoogleMapMarker *fakeAirMarker = (AIRGoogleMapMarker *) airMarker.fakeMarker;
612
723
  AIRGoogleMapMarker *fakeSelectedMarker = (AIRGoogleMapMarker *) selectedMarker.fakeMarker;
613
-
724
+
614
725
  if (airMarker && airMarker.onDeselect) {
615
726
  airMarker.onDeselect([fakeAirMarker makeEventData:@"marker-deselect"]);
616
727
  }
@@ -618,7 +729,7 @@ id regionAsJSON(MKCoordinateRegion region) {
618
729
  if (airMarker && self.onMarkerDeselect) {
619
730
  self.onMarkerDeselect([fakeAirMarker makeEventData:@"marker-deselect"]);
620
731
  }
621
-
732
+
622
733
  if (selectedMarker && selectedMarker.onSelect) {
623
734
  selectedMarker.onSelect([fakeSelectedMarker makeEventData:@"marker-select"]);
624
735
  }
@@ -665,6 +776,63 @@ id regionAsJSON(MKCoordinateRegion region) {
665
776
  return [map cameraForBounds:bounds insets:UIEdgeInsetsZero];
666
777
  }
667
778
 
779
+ #pragma mark - RNMapsAirModuleDelegate
780
+
781
+ - (NSDictionary *) getCoordinatesForPoint:(CGPoint)point
782
+ {
783
+ CLLocationCoordinate2D coordinate = [self.projection coordinateForPoint:point];
784
+ return @{
785
+ @"latitude": @(coordinate.latitude),
786
+ @"longitude": @(coordinate.longitude),
787
+ };
788
+ }
789
+
790
+ - (NSDictionary *) getPointForCoordinates:(CLLocationCoordinate2D)location
791
+ {
792
+ CGPoint touchPoint = [self.projection pointForCoordinate:location];
793
+ return @{
794
+ @"x": @(touchPoint.x),
795
+ @"y": @(touchPoint.y),
796
+ };
797
+ }
798
+
799
+ -(void) takeSnapshotWithConfig:(NSDictionary *)config success:(RCTPromiseResolveBlock)success error:(RCTPromiseRejectBlock)error {
800
+ /* unused
801
+ NSNumber *width = [config objectForKey:@"width"];
802
+ NSNumber *height = [config objectForKey:@"height"];
803
+ */
804
+ NSNumber *quality = [config objectForKey:@"quality"];
805
+
806
+ NSString *format = [config objectForKey:@"format"];
807
+ NSString *result = [config objectForKey:@"result"];
808
+ NSTimeInterval timeStamp = [[NSDate date] timeIntervalSince1970];
809
+ NSString *pathComponent = [NSString stringWithFormat:@"Documents/snapshot-%.20lf.%@", timeStamp, format];
810
+ NSString *filePath = [NSHomeDirectory() stringByAppendingPathComponent: pathComponent];
811
+
812
+ // TODO: currently we are ignoring width, height, region
813
+
814
+ UIGraphicsBeginImageContextWithOptions(self.frame.size, YES, 0.0f);
815
+ [self.layer renderInContext:UIGraphicsGetCurrentContext()];
816
+ UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
817
+
818
+ NSData *data;
819
+ if ([format isEqualToString:@"png"]) {
820
+ data = UIImagePNGRepresentation(image);
821
+
822
+ } else if([format isEqualToString:@"jpg"]) {
823
+ data = UIImageJPEGRepresentation(image, quality.floatValue);
824
+ }
825
+
826
+ if ([result isEqualToString:@"file"]) {
827
+ [data writeToFile:filePath atomically:YES];
828
+ success(filePath);
829
+ } else if ([result isEqualToString:@"base64"]) {
830
+ success([data base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithCarriageReturn]);
831
+ }
832
+
833
+ UIGraphicsEndImageContext();
834
+ }
835
+
668
836
  #pragma mark - Utils
669
837
 
670
838
  - (CGRect) frameForMarker:(AIRGoogleMapMarker*) mrkView {
@@ -919,6 +1087,51 @@ id regionAsJSON(MKCoordinateRegion region) {
919
1087
  return _kmlSrc;
920
1088
  }
921
1089
 
1090
+ - (void) setKMLData:(NSData *) urlData {
1091
+ GMUKMLParser *parser = [[GMUKMLParser alloc] initWithData:urlData];
1092
+ [parser parse];
1093
+
1094
+ NSUInteger index = 0;
1095
+ NSMutableArray *markers = [[NSMutableArray alloc]init];
1096
+
1097
+ for (GMUPlacemark *place in parser.placemarks) {
1098
+
1099
+ CLLocationCoordinate2D location =((GMUPoint *) place.geometry).coordinate;
1100
+
1101
+ AIRGoogleMapMarker *marker = (AIRGoogleMapMarker *)[[AIRGoogleMapMarkerManager alloc] view];
1102
+ if (!marker.bridge) {
1103
+ marker.bridge = _bridge;
1104
+ }
1105
+ marker.identifier = place.title;
1106
+ marker.coordinate = location;
1107
+ marker.title = place.title;
1108
+ marker.subtitle = place.snippet;
1109
+ marker.pinColor = place.style.fillColor;
1110
+ marker.imageSrc = [AIRGoogleMap GetIconUrl:place parser:parser];
1111
+ marker.layer.backgroundColor = [UIColor clearColor].CGColor;
1112
+ marker.layer.position = CGPointZero;
1113
+
1114
+ [self insertReactSubview:(UIView *) marker atIndex:index];
1115
+
1116
+ [markers addObject:@{@"id": marker.identifier,
1117
+ @"title": marker.title,
1118
+ @"description": marker.subtitle,
1119
+ @"coordinate": @{
1120
+ @"latitude": @(location.latitude),
1121
+ @"longitude": @(location.longitude)
1122
+ }
1123
+ }];
1124
+
1125
+ index++;
1126
+ }
1127
+
1128
+ id event = @{@"markers": markers};
1129
+ if (self.onKmlReady) self.onKmlReady(event);
1130
+ #else
1131
+ REQUIRES_GOOGLE_MAPS_UTILS();
1132
+ #endif
1133
+ }
1134
+
922
1135
  - (void)setKmlSrc:(NSString *)kmlUrl {
923
1136
  #ifdef HAVE_GOOGLE_MAPS_UTILS
924
1137
 
@@ -928,53 +1141,28 @@ id regionAsJSON(MKCoordinateRegion region) {
928
1141
  NSData *urlData = nil;
929
1142
 
930
1143
  if ([url isFileURL]) {
931
- urlData = [NSData dataWithContentsOfURL:url];
1144
+ [self setKMLData:[NSData dataWithContentsOfURL:url]];
932
1145
  } else {
933
- urlData = [[NSFileManager defaultManager] contentsAtPath:kmlUrl];
934
- }
935
-
936
- GMUKMLParser *parser = [[GMUKMLParser alloc] initWithData:urlData];
937
- [parser parse];
938
-
939
- NSUInteger index = 0;
940
- NSMutableArray *markers = [[NSMutableArray alloc]init];
941
-
942
- for (GMUPlacemark *place in parser.placemarks) {
943
-
944
- CLLocationCoordinate2D location =((GMUPoint *) place.geometry).coordinate;
945
-
946
- AIRGoogleMapMarker *marker = (AIRGoogleMapMarker *)[[AIRGoogleMapMarkerManager alloc] view];
947
- if (!marker.bridge) {
948
- marker.bridge = _bridge;
949
- }
950
- marker.identifier = place.title;
951
- marker.coordinate = location;
952
- marker.title = place.title;
953
- marker.subtitle = place.snippet;
954
- marker.pinColor = place.style.fillColor;
955
- marker.imageSrc = [AIRGoogleMap GetIconUrl:place parser:parser];
956
- marker.layer.backgroundColor = [UIColor clearColor].CGColor;
957
- marker.layer.position = CGPointZero;
958
-
959
- [self insertReactSubview:(UIView *) marker atIndex:index];
960
-
961
- [markers addObject:@{@"id": marker.identifier,
962
- @"title": marker.title,
963
- @"description": marker.subtitle,
964
- @"coordinate": @{
965
- @"latitude": @(location.latitude),
966
- @"longitude": @(location.longitude)
967
- }
968
- }];
969
-
970
- index++;
1146
+ __weak AIRGoogleMap *weakSelf = self;
1147
+
1148
+ NSURLSession *session = [NSURLSession sharedSession];
1149
+ NSURLSessionDataTask *dataTask = [session dataTaskWithURL:url
1150
+ completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
1151
+ if (error) {
1152
+ NSLog(@"Error fetching data: %@", error.localizedDescription);
1153
+ return;
1154
+ } else {
1155
+ dispatch_async(dispatch_get_main_queue(), ^{
1156
+ AIRGoogleMap *strongSelf = weakSelf;
1157
+ [strongSelf setKMLData:data];
1158
+ });
1159
+
1160
+ }
1161
+ }];
1162
+ [dataTask resume];
971
1163
  }
972
1164
 
973
- id event = @{@"markers": markers};
974
- if (self.onKmlReady) self.onKmlReady(event);
975
- #else
976
- REQUIRES_GOOGLE_MAPS_UTILS();
977
- #endif
1165
+
978
1166
  }
979
1167
 
980
1168
 
@@ -1034,7 +1222,7 @@ id regionAsJSON(MKCoordinateRegion region) {
1034
1222
  }
1035
1223
  // do nothing, passed as options on initialization
1036
1224
  - (void)setLoadingBackgroundColor:(UIColor *)loadingBackgroundColor {
1037
-
1225
+
1038
1226
  }
1039
1227
 
1040
1228
 
@@ -7,7 +7,6 @@
7
7
  #ifdef HAVE_GOOGLE_MAPS
8
8
 
9
9
  #import <GoogleMaps/GoogleMaps.h>
10
- #import "AIRMapCoordinate.h"
11
10
 
12
11
  @interface AIRGoogleMapCircle : UIView
13
12
 
@@ -25,20 +25,32 @@
25
25
  }
26
26
  return self;
27
27
  }
28
+ - (void) prepare
29
+ {
30
+ if(_didMoveToWindow) return;
31
+ _didMoveToWindow = true;
32
+ if(_fillColor) {
33
+ _circle.fillColor = _fillColor;
34
+ }
35
+ if(_strokeColor) {
36
+ _circle.strokeColor = _strokeColor;
37
+ }
38
+ if(_strokeWidth) {
39
+ _circle.strokeWidth = _strokeWidth;
40
+ }
41
+ if (_zIndex) {
42
+ _circle.zIndex = _zIndex;
43
+ }
44
+ }
45
+ - (void) didMoveToSuperview
46
+ {
47
+ [super didMoveToSuperview];
48
+ [self prepare];
49
+ }
28
50
 
29
51
  - (void)didMoveToWindow {
30
52
  [super didMoveToWindow];
31
- if(_didMoveToWindow) return;
32
- _didMoveToWindow = true;
33
- if(_fillColor) {
34
- _circle.fillColor = _fillColor;
35
- }
36
- if(_strokeColor) {
37
- _circle.strokeColor = _strokeColor;
38
- }
39
- if(_strokeWidth) {
40
- _circle.strokeWidth = _strokeWidth;
41
- }
53
+ [self prepare];
42
54
  }
43
55
 
44
56
  - (void)setRadius:(double)radius
@@ -0,0 +1,13 @@
1
+ //
2
+ // Created by Leland Richardson on 12/27/15.
3
+ // Copyright (c) 2015 Facebook. All rights reserved.
4
+ //
5
+
6
+ #import <Foundation/Foundation.h>
7
+ #import <MapKit/MapKit.h>
8
+
9
+ @interface AIRGoogleMapCoordinate : NSObject
10
+
11
+ @property (nonatomic, assign) CLLocationCoordinate2D coordinate;
12
+
13
+ @end
@@ -0,0 +1,10 @@
1
+ //
2
+ // Created by Leland Richardson on 12/27/15.
3
+ // Copyright (c) 2015 Facebook. All rights reserved.
4
+ //
5
+
6
+ #import "AIRGoogleMapCoordinate.h"
7
+
8
+
9
+ @implementation AIRGoogleMapCoordinate
10
+ @end
@@ -9,8 +9,15 @@
9
9
 
10
10
  #import <React/RCTViewManager.h>
11
11
 
12
+ @class GMSCameraPosition;
13
+
12
14
  @interface AIRGoogleMapManager : RCTViewManager
13
15
 
16
+ @property (nonatomic, strong) NSString* googleMapId;
17
+ @property (nonatomic) BOOL zoomTapEnabled;
18
+ @property (nonatomic, strong) UIColor* backgroundColor;
19
+ @property (nonatomic, strong) GMSCameraPosition* camera;
20
+
14
21
  @property (nonatomic, strong) NSDictionary *initialProps;
15
22
 
16
23
  @property (nonatomic) BOOL isGesture;