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.
- package/android/build.gradle +30 -6
- package/android/generated/java/com/facebook/fbreact/specs/NativeAirMapsModuleSpec.java +63 -0
- package/android/generated/jni/CMakeLists.txt +36 -0
- package/android/generated/jni/RNMapsSpecs-generated.cpp +68 -0
- package/android/generated/jni/RNMapsSpecs.h +31 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/ComponentDescriptors.cpp +25 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/ComponentDescriptors.h +27 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/EventEmitters.cpp +896 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/EventEmitters.h +765 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/Props.cpp +146 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/Props.h +1047 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/RNMapsSpecsJSI-generated.cpp +74 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/RNMapsSpecsJSI.h +264 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/ShadowNodes.cpp +20 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/ShadowNodes.h +65 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/States.cpp +16 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/States.h +65 -0
- package/android/src/main/java/com/rnmaps/fabric/NativeAirMapsModule.java +2 -1
- package/android/src/main/java/com/rnmaps/maps/MapAirModulePackage.java +1 -1
- package/ios/AirGoogleMaps/AIRGoogleMap.h +8 -2
- package/ios/AirGoogleMaps/AIRGoogleMap.m +243 -55
- package/ios/AirGoogleMaps/AIRGoogleMapCircle.h +0 -1
- package/ios/AirGoogleMaps/AIRGoogleMapCircle.m +23 -11
- package/ios/AirGoogleMaps/AIRGoogleMapCoordinate.h +13 -0
- package/ios/AirGoogleMaps/AIRGoogleMapCoordinate.m +10 -0
- package/ios/AirGoogleMaps/AIRGoogleMapManager.h +7 -0
- package/ios/AirGoogleMaps/AIRGoogleMapManager.m +30 -119
- package/ios/AirGoogleMaps/AIRGoogleMapMarker.h +2 -0
- package/ios/AirGoogleMaps/AIRGoogleMapMarker.m +347 -243
- package/ios/AirGoogleMaps/AIRGoogleMapMarkerManager.m +0 -1
- package/ios/AirGoogleMaps/AIRGoogleMapOverlay.h +0 -1
- package/ios/AirGoogleMaps/AIRGoogleMapPolygon.h +5 -4
- package/ios/AirGoogleMaps/AIRGoogleMapPolygon.m +32 -2
- package/ios/AirGoogleMaps/AIRGoogleMapPolygonManager.m +3 -3
- package/ios/AirGoogleMaps/AIRGoogleMapPolyline.h +3 -2
- package/ios/AirGoogleMaps/AIRGoogleMapPolyline.m +2 -3
- package/ios/AirGoogleMaps/AIRGoogleMapPolylineManager.m +2 -2
- package/ios/AirGoogleMaps/AIRGoogleMapWMSTile.h +1 -1
- package/ios/AirGoogleMaps/AIRGoogleMapWMSTile.m +2 -2
- package/ios/AirGoogleMaps/RCTConvert+GMSMapViewType.h +3 -0
- package/ios/AirGoogleMaps/RCTConvert+GMSMapViewType.m +18 -0
- package/ios/AirGoogleMaps/RNMapsGoogleMapView.h +26 -0
- package/ios/AirGoogleMaps/RNMapsGoogleMapView.mm +629 -0
- package/ios/AirGoogleMaps/RNMapsGoogleMapViewManager.mm +25 -0
- package/ios/AirGoogleMaps/RNMapsGooglePolygonView.h +26 -0
- package/ios/AirGoogleMaps/RNMapsGooglePolygonView.mm +217 -0
- package/ios/AirGoogleMaps/RNMapsGooglePolygonViewManager.mm +25 -0
- package/ios/AirMaps/AIRMap.h +8 -5
- package/ios/AirMaps/AIRMap.m +292 -141
- package/ios/AirMaps/AIRMapManager.m +12 -21
- package/ios/AirMaps/AIRMapMarker.h +1 -0
- package/ios/AirMaps/AIRMapMarker.m +165 -103
- package/ios/AirMaps/Callout/SMCalloutView.m +1 -1
- package/ios/AirMaps/RCTConvert+AirMap.h +4 -0
- package/ios/AirMaps/RCTConvert+AirMap.m +2 -0
- package/ios/AirMaps/RNMapsAirModule.h +4 -1
- package/ios/AirMaps/RNMapsAirModule.mm +42 -172
- package/ios/AirMaps/RNMapsAirModuleDelegate.h +24 -0
- package/ios/AirMaps/RNMapsHostVewDelegate.h +17 -0
- package/ios/AirMaps/RNMapsMapView.h +6 -3
- package/ios/AirMaps/RNMapsMapView.mm +346 -332
- package/ios/AirMaps/RNMapsMarkerView.h +24 -0
- package/ios/AirMaps/RNMapsMarkerView.mm +430 -0
- package/ios/AirMaps/RNMapsMarkerViewManager.mm +21 -0
- package/ios/AirMaps/UIView +AirMap.m +20 -0
- package/ios/AirMaps/UIView+AirMap.h +11 -0
- package/ios/AirMaps.xcodeproj/project.pbxproj +60 -0
- package/ios/generated/RNMapsSpecs/ComponentDescriptors.cpp +25 -0
- package/ios/generated/RNMapsSpecs/ComponentDescriptors.h +27 -0
- package/ios/generated/RNMapsSpecs/EventEmitters.cpp +896 -0
- package/ios/generated/RNMapsSpecs/EventEmitters.h +765 -0
- package/ios/generated/RNMapsSpecs/Props.cpp +146 -0
- package/ios/generated/RNMapsSpecs/Props.h +1047 -0
- package/ios/generated/RNMapsSpecs/RCTComponentViewHelpers.h +549 -0
- package/ios/generated/RNMapsSpecs/RNMapsSpecs-generated.mm +92 -0
- package/ios/generated/RNMapsSpecs/RNMapsSpecs.h +134 -0
- package/ios/generated/RNMapsSpecs/ShadowNodes.cpp +20 -0
- package/ios/generated/RNMapsSpecs/ShadowNodes.h +65 -0
- package/ios/generated/RNMapsSpecs/States.cpp +16 -0
- package/ios/generated/RNMapsSpecs/States.h +65 -0
- package/ios/generated/RNMapsSpecsJSI-generated.cpp +74 -0
- package/ios/generated/RNMapsSpecsJSI.h +264 -0
- package/lib/MapMarker.d.ts +15 -2
- package/lib/MapMarker.js +53 -9
- package/lib/MapMarkerNativeComponent.js +0 -2
- package/lib/MapOverlay.d.ts +1 -1
- package/lib/MapOverlay.js +2 -8
- package/lib/MapView.d.ts +5 -22
- package/lib/MapView.js +34 -21
- package/lib/{FabricMapView.d.ts → createFabricMap.d.ts} +7 -6
- package/lib/createFabricMap.js +175 -0
- package/lib/decorateMapComponent.js +18 -0
- package/lib/specs/NativeAirMapsModule.d.ts +2 -2
- package/lib/specs/NativeComponentGoogleMapView.d.ts +713 -0
- package/lib/specs/NativeComponentGoogleMapView.js +21 -0
- package/lib/specs/NativeComponentGooglePolygon.d.ts +75 -0
- package/lib/specs/NativeComponentGooglePolygon.js +9 -0
- package/lib/specs/NativeComponentMapView.d.ts +21 -45
- package/lib/specs/NativeComponentMarker.d.ts +258 -0
- package/lib/specs/NativeComponentMarker.js +21 -0
- package/package.json +12 -6
- package/react-native-maps.podspec +2 -1
- 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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
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)
|
|
693
|
+
- (void)setMinZoom:(CGFloat)minZoomLevel {
|
|
583
694
|
[self setMinZoom:minZoomLevel maxZoom:self.maxZoom ];
|
|
584
695
|
}
|
|
585
696
|
|
|
586
|
-
- (void)
|
|
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
|
-
|
|
1144
|
+
[self setKMLData:[NSData dataWithContentsOfURL:url]];
|
|
932
1145
|
} else {
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
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
|
-
|
|
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
|
|
|
@@ -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
|
-
|
|
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
|
|
@@ -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;
|