react-native-maps 1.21.0-alpha.6 → 1.21.0-alpha.8
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/ios/AirGoogleMaps/AIRGoogleMap.h +6 -1
- package/ios/AirGoogleMaps/AIRGoogleMap.m +90 -7
- package/ios/AirGoogleMaps/AIRGoogleMapCircle.h +0 -1
- 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 +13 -91
- package/ios/AirGoogleMaps/AIRGoogleMapMarkerManager.m +0 -1
- package/ios/AirGoogleMaps/AIRGoogleMapOverlay.h +0 -1
- package/ios/AirGoogleMaps/AIRGoogleMapPolygon.h +3 -3
- package/ios/AirGoogleMaps/AIRGoogleMapPolygon.m +2 -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/RCTConvert+GMSMapViewType.h +3 -0
- package/ios/AirGoogleMaps/RCTConvert+GMSMapViewType.m +16 -0
- package/ios/AirGoogleMaps/RNMapsGoogleMapView.h +26 -0
- package/ios/AirGoogleMaps/RNMapsGoogleMapView.mm +531 -0
- package/ios/AirGoogleMaps/RNMapsGoogleMapViewManager.mm +25 -0
- package/ios/AirMaps/AIRMap.h +4 -4
- package/ios/AirMaps/AIRMap.m +14 -2
- package/ios/AirMaps/AIRMapManager.m +6 -21
- package/ios/AirMaps/RCTConvert+AirMap.h +4 -0
- package/ios/AirMaps/RCTConvert+AirMap.m +2 -0
- package/ios/AirMaps/RNMapsAirModule.h +3 -0
- package/ios/AirMaps/RNMapsMapView.h +3 -0
- package/ios/AirMaps/RNMapsMapView.mm +12 -25
- package/lib/MapOverlay.d.ts +1 -1
- package/lib/MapView.d.ts +2 -2
- package/lib/MapView.js +20 -18
- package/lib/{FabricMapView.d.ts → createFabricMap.d.ts} +7 -6
- package/lib/createFabricMap.js +175 -0
- package/lib/specs/NativeComponentGoogleMapView.d.ts +713 -0
- package/lib/specs/NativeComponentGoogleMapView.js +21 -0
- package/lib/specs/NativeComponentMapView.d.ts +4 -11
- package/package.json +7 -7
- package/lib/FabricMapView.js +0 -175
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
#import <GoogleMaps/GoogleMaps.h>
|
|
14
14
|
#import <MapKit/MapKit.h>
|
|
15
15
|
#import "AIRGMSMarker.h"
|
|
16
|
-
|
|
16
|
+
|
|
17
|
+
#import "AIRGoogleMapCoordinate.h"
|
|
17
18
|
|
|
18
19
|
@interface AIRGoogleMap : GMSMapView
|
|
19
20
|
|
|
@@ -84,6 +85,10 @@
|
|
|
84
85
|
|
|
85
86
|
- (NSDictionary*) getMarkersFramesWithOnlyVisible:(BOOL)onlyVisible;
|
|
86
87
|
- (instancetype)initWithMapId:(NSString *)mapId initialCamera:(GMSCameraPosition*) camera backgroundColor:(UIColor *) backgroundColor andZoomTapEnabled:(BOOL)zoomTapEnabled;
|
|
88
|
+
-(void) fitToSuppliedMarkers:(NSArray*) markers withEdgePadding:(NSDictionary*) edgePadding animated:(BOOL)animated;
|
|
89
|
+
-(void) fitToCoordinates:(NSArray<AIRGoogleMapCoordinate *> *) coordinates withEdgePadding:(NSDictionary*) edgePadding animated:(BOOL)animated;
|
|
90
|
+
-(void) fitToElementsWithEdgePadding:(nonnull NSDictionary *)edgePadding
|
|
91
|
+
animated:(BOOL)animated;
|
|
87
92
|
@end
|
|
88
93
|
|
|
89
94
|
#endif
|
|
@@ -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
|
|
@@ -86,7 +87,7 @@ id regionAsJSON(MKCoordinateRegion region) {
|
|
|
86
87
|
[options setCamera:camera];
|
|
87
88
|
}
|
|
88
89
|
self = [super initWithOptions:options];
|
|
89
|
-
|
|
90
|
+
|
|
90
91
|
if (self) {
|
|
91
92
|
_reactSubviews = [NSMutableArray new];
|
|
92
93
|
_markers = [NSMutableArray array];
|
|
@@ -145,6 +146,88 @@ id regionAsJSON(MKCoordinateRegion region) {
|
|
|
145
146
|
};
|
|
146
147
|
}
|
|
147
148
|
|
|
149
|
+
-(void) fitToCoordinates:(NSArray<AIRGoogleMapCoordinate *> *) coordinates withEdgePadding:(NSDictionary*) edgePadding animated:(BOOL)animated
|
|
150
|
+
{
|
|
151
|
+
CLLocationCoordinate2D myLocation = coordinates.firstObject.coordinate;
|
|
152
|
+
GMSCoordinateBounds *bounds = [[GMSCoordinateBounds alloc] initWithCoordinate:myLocation coordinate:myLocation];
|
|
153
|
+
|
|
154
|
+
for (AIRGoogleMapCoordinate *coordinate in coordinates)
|
|
155
|
+
bounds = [bounds includingCoordinate:coordinate.coordinate];
|
|
156
|
+
|
|
157
|
+
// Set Map viewport
|
|
158
|
+
CGFloat top = [RCTConvert CGFloat:edgePadding[@"top"]];
|
|
159
|
+
CGFloat right = [RCTConvert CGFloat:edgePadding[@"right"]];
|
|
160
|
+
CGFloat bottom = [RCTConvert CGFloat:edgePadding[@"bottom"]];
|
|
161
|
+
CGFloat left = [RCTConvert CGFloat:edgePadding[@"left"]];
|
|
162
|
+
|
|
163
|
+
GMSCameraUpdate *cameraUpdate = [GMSCameraUpdate fitBounds:bounds withEdgeInsets:UIEdgeInsetsMake(top, left, bottom, right)];
|
|
164
|
+
|
|
165
|
+
if (animated) {
|
|
166
|
+
[self animateWithCameraUpdate: cameraUpdate];
|
|
167
|
+
} else {
|
|
168
|
+
[self moveCamera: cameraUpdate];
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
-(void) fitToElementsWithEdgePadding:(nonnull NSDictionary *)edgePadding
|
|
173
|
+
animated:(BOOL)animated
|
|
174
|
+
{
|
|
175
|
+
CLLocationCoordinate2D myLocation = ((AIRGoogleMapMarker *)(self.markers.firstObject)).realMarker.position;
|
|
176
|
+
GMSCoordinateBounds *bounds = [[GMSCoordinateBounds alloc] initWithCoordinate:myLocation coordinate:myLocation];
|
|
177
|
+
|
|
178
|
+
for (AIRGoogleMapMarker *marker in self.markers)
|
|
179
|
+
bounds = [bounds includingCoordinate:marker.realMarker.position];
|
|
180
|
+
|
|
181
|
+
GMSCameraUpdate* cameraUpdate;
|
|
182
|
+
|
|
183
|
+
if ([edgePadding count] != 0) {
|
|
184
|
+
// Set Map viewport
|
|
185
|
+
CGFloat top = [RCTConvert CGFloat:edgePadding[@"top"]];
|
|
186
|
+
CGFloat right = [RCTConvert CGFloat:edgePadding[@"right"]];
|
|
187
|
+
CGFloat bottom = [RCTConvert CGFloat:edgePadding[@"bottom"]];
|
|
188
|
+
CGFloat left = [RCTConvert CGFloat:edgePadding[@"left"]];
|
|
189
|
+
|
|
190
|
+
cameraUpdate = [GMSCameraUpdate fitBounds:bounds withEdgeInsets:UIEdgeInsetsMake(top, left, bottom, right)];
|
|
191
|
+
} else {
|
|
192
|
+
cameraUpdate = [GMSCameraUpdate fitBounds:bounds withPadding:55.0f];
|
|
193
|
+
}
|
|
194
|
+
if (animated) {
|
|
195
|
+
[self animateWithCameraUpdate: cameraUpdate];
|
|
196
|
+
} else {
|
|
197
|
+
[self moveCamera: cameraUpdate];
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
- (void) fitToSuppliedMarkers:(NSArray*) markers withEdgePadding:(NSDictionary*) edgePadding animated:(BOOL)animated
|
|
202
|
+
{
|
|
203
|
+
NSPredicate *filterMarkers = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings) {
|
|
204
|
+
AIRGoogleMapMarker *marker = (AIRGoogleMapMarker *)evaluatedObject;
|
|
205
|
+
return [marker isKindOfClass:[AIRGoogleMapMarker class]] && [markers containsObject:marker.identifier];
|
|
206
|
+
}];
|
|
207
|
+
|
|
208
|
+
NSArray *filteredMarkers = [self.markers filteredArrayUsingPredicate:filterMarkers];
|
|
209
|
+
|
|
210
|
+
CLLocationCoordinate2D myLocation = ((AIRGoogleMapMarker *)(filteredMarkers.firstObject)).realMarker.position;
|
|
211
|
+
GMSCoordinateBounds *bounds = [[GMSCoordinateBounds alloc] initWithCoordinate:myLocation coordinate:myLocation];
|
|
212
|
+
|
|
213
|
+
for (AIRGoogleMapMarker *marker in filteredMarkers)
|
|
214
|
+
bounds = [bounds includingCoordinate:marker.realMarker.position];
|
|
215
|
+
|
|
216
|
+
// Set Map viewport
|
|
217
|
+
CGFloat top = [RCTConvert CGFloat:edgePadding[@"top"]];
|
|
218
|
+
CGFloat right = [RCTConvert CGFloat:edgePadding[@"right"]];
|
|
219
|
+
CGFloat bottom = [RCTConvert CGFloat:edgePadding[@"bottom"]];
|
|
220
|
+
CGFloat left = [RCTConvert CGFloat:edgePadding[@"left"]];
|
|
221
|
+
|
|
222
|
+
GMSCameraUpdate* cameraUpdate = [GMSCameraUpdate fitBounds:bounds withEdgeInsets:UIEdgeInsetsMake(top, left, bottom, right)];
|
|
223
|
+
if (animated) {
|
|
224
|
+
[self animateWithCameraUpdate:cameraUpdate
|
|
225
|
+
];
|
|
226
|
+
} else {
|
|
227
|
+
[self moveCamera: cameraUpdate];
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
148
231
|
#pragma clang diagnostic push
|
|
149
232
|
#pragma clang diagnostic ignored "-Wobjc-missing-super-calls"
|
|
150
233
|
- (void)insertReactSubview:(id<RCTComponent>)subview atIndex:(NSInteger)atIndex {
|
|
@@ -579,11 +662,11 @@ id regionAsJSON(MKCoordinateRegion region) {
|
|
|
579
662
|
return self.settings.myLocationButton;
|
|
580
663
|
}
|
|
581
664
|
|
|
582
|
-
- (void)
|
|
665
|
+
- (void)setMinZoom:(CGFloat)minZoomLevel {
|
|
583
666
|
[self setMinZoom:minZoomLevel maxZoom:self.maxZoom ];
|
|
584
667
|
}
|
|
585
668
|
|
|
586
|
-
- (void)
|
|
669
|
+
- (void)setMaxZoom:(CGFloat)maxZoomLevel {
|
|
587
670
|
[self setMinZoom:self.minZoom maxZoom:maxZoomLevel ];
|
|
588
671
|
}
|
|
589
672
|
|
|
@@ -610,7 +693,7 @@ id regionAsJSON(MKCoordinateRegion region) {
|
|
|
610
693
|
AIRGMSMarker *airMarker = (AIRGMSMarker *) self.selectedMarker;
|
|
611
694
|
AIRGoogleMapMarker *fakeAirMarker = (AIRGoogleMapMarker *) airMarker.fakeMarker;
|
|
612
695
|
AIRGoogleMapMarker *fakeSelectedMarker = (AIRGoogleMapMarker *) selectedMarker.fakeMarker;
|
|
613
|
-
|
|
696
|
+
|
|
614
697
|
if (airMarker && airMarker.onDeselect) {
|
|
615
698
|
airMarker.onDeselect([fakeAirMarker makeEventData:@"marker-deselect"]);
|
|
616
699
|
}
|
|
@@ -618,7 +701,7 @@ id regionAsJSON(MKCoordinateRegion region) {
|
|
|
618
701
|
if (airMarker && self.onMarkerDeselect) {
|
|
619
702
|
self.onMarkerDeselect([fakeAirMarker makeEventData:@"marker-deselect"]);
|
|
620
703
|
}
|
|
621
|
-
|
|
704
|
+
|
|
622
705
|
if (selectedMarker && selectedMarker.onSelect) {
|
|
623
706
|
selectedMarker.onSelect([fakeSelectedMarker makeEventData:@"marker-select"]);
|
|
624
707
|
}
|
|
@@ -1034,7 +1117,7 @@ id regionAsJSON(MKCoordinateRegion region) {
|
|
|
1034
1117
|
}
|
|
1035
1118
|
// do nothing, passed as options on initialization
|
|
1036
1119
|
- (void)setLoadingBackgroundColor:(UIColor *)loadingBackgroundColor {
|
|
1037
|
-
|
|
1120
|
+
|
|
1038
1121
|
}
|
|
1039
1122
|
|
|
1040
1123
|
|
|
@@ -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;
|
|
@@ -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 "
|
|
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
|
-
|
|
46
|
+
_googleMapId = self.initialProps[@"googleMapId"];
|
|
56
47
|
}
|
|
57
48
|
if (self.initialProps[@"zoomTapEnabled"]){
|
|
58
|
-
|
|
49
|
+
_zoomTapEnabled = self.initialProps[@"zoomTapEnabled"];
|
|
59
50
|
}
|
|
60
51
|
if (self.initialProps[@"loadingBackgroundColor"]){
|
|
61
|
-
|
|
52
|
+
_backgroundColor = [RCTConvert UIColor:self.initialProps[@"loadingBackgroundColor"]];
|
|
62
53
|
}
|
|
63
54
|
if (self.initialProps[@"initialCamera"]){
|
|
64
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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<
|
|
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
|
}
|
|
@@ -9,15 +9,15 @@
|
|
|
9
9
|
#import <GoogleMaps/GoogleMaps.h>
|
|
10
10
|
#import <React/RCTBridge.h>
|
|
11
11
|
#import "AIRGMSPolygon.h"
|
|
12
|
-
#import "
|
|
12
|
+
#import "AIRGoogleMapCoordinate.h"
|
|
13
13
|
|
|
14
14
|
@interface AIRGoogleMapPolygon : UIView
|
|
15
15
|
|
|
16
16
|
@property (nonatomic, weak) RCTBridge *bridge;
|
|
17
17
|
@property (nonatomic, strong) NSString *identifier;
|
|
18
18
|
@property (nonatomic, strong) AIRGMSPolygon *polygon;
|
|
19
|
-
@property (nonatomic, strong) NSArray<
|
|
20
|
-
@property (nonatomic, strong) NSArray<NSArray<
|
|
19
|
+
@property (nonatomic, strong) NSArray<AIRGoogleMapCoordinate *> *coordinates;
|
|
20
|
+
@property (nonatomic, strong) NSArray<NSArray<AIRGoogleMapCoordinate *> *> *holes;
|
|
21
21
|
@property (nonatomic, copy) RCTBubblingEventBlock onPress;
|
|
22
22
|
|
|
23
23
|
@property (nonatomic, strong) UIColor *fillColor;
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
- (void)setCoordinates:(NSArray<
|
|
45
|
+
- (void)setCoordinates:(NSArray<AIRGoogleMapCoordinate *> *)coordinates
|
|
46
46
|
{
|
|
47
47
|
_coordinates = coordinates;
|
|
48
48
|
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
_polygon.path = path;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
- (void)setHoles:(NSArray<NSArray<
|
|
58
|
+
- (void)setHoles:(NSArray<NSArray<AIRGoogleMapCoordinate *> *> *)holes
|
|
59
59
|
{
|
|
60
60
|
_holes = holes;
|
|
61
61
|
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
#import <React/RCTEventDispatcher.h>
|
|
14
14
|
#import <React/RCTViewManager.h>
|
|
15
15
|
#import <React/UIView+React.h>
|
|
16
|
-
#import "RCTConvert+AirMap.h"
|
|
17
16
|
#import "AIRGoogleMapPolygon.h"
|
|
17
|
+
#import "RCTConvert+GMSMapViewType.h"
|
|
18
18
|
|
|
19
19
|
@interface AIRGoogleMapPolygonManager()
|
|
20
20
|
|
|
@@ -31,8 +31,8 @@ RCT_EXPORT_MODULE()
|
|
|
31
31
|
return polygon;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
RCT_EXPORT_VIEW_PROPERTY(coordinates,
|
|
35
|
-
RCT_EXPORT_VIEW_PROPERTY(holes,
|
|
34
|
+
RCT_EXPORT_VIEW_PROPERTY(coordinates, AIRGoogleMapCoordinateArray)
|
|
35
|
+
RCT_EXPORT_VIEW_PROPERTY(holes, AIRGoogleMapCoordinateArrayArray)
|
|
36
36
|
RCT_EXPORT_VIEW_PROPERTY(fillColor, UIColor)
|
|
37
37
|
RCT_EXPORT_VIEW_PROPERTY(strokeWidth, double)
|
|
38
38
|
RCT_EXPORT_VIEW_PROPERTY(strokeColor, UIColor)
|
|
@@ -9,15 +9,16 @@
|
|
|
9
9
|
#import <GoogleMaps/GoogleMaps.h>
|
|
10
10
|
#import <React/RCTBridge.h>
|
|
11
11
|
#import "AIRGMSPolyline.h"
|
|
12
|
-
#import "AIRMapCoordinate.h"
|
|
13
12
|
#import "AIRGoogleMapMarker.h"
|
|
14
13
|
|
|
14
|
+
#import "AIRGoogleMapCoordinate.h"
|
|
15
|
+
|
|
15
16
|
@interface AIRGoogleMapPolyline : UIView
|
|
16
17
|
|
|
17
18
|
@property (nonatomic, weak) RCTBridge *bridge;
|
|
18
19
|
@property (nonatomic, strong) NSString *identifier;
|
|
19
20
|
@property (nonatomic, strong) AIRGMSPolyline *polyline;
|
|
20
|
-
@property (nonatomic, strong) NSArray<
|
|
21
|
+
@property (nonatomic, strong) NSArray<AIRGoogleMapCoordinate *> *coordinates;
|
|
21
22
|
@property (nonatomic, copy) RCTBubblingEventBlock onPress;
|
|
22
23
|
@property (nonatomic, strong) GMSMapView *originalMap;
|
|
23
24
|
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
#import <UIKit/UIKit.h>
|
|
9
9
|
#import "AIRGoogleMapPolyline.h"
|
|
10
10
|
#import "AIRGMSPolyline.h"
|
|
11
|
-
#import "AIRMapCoordinate.h"
|
|
12
11
|
#import "AIRGoogleMapMarker.h"
|
|
13
12
|
#import "AIRGoogleMapMarkerManager.h"
|
|
14
13
|
#import <GoogleMaps/GoogleMaps.h>
|
|
@@ -26,13 +25,13 @@
|
|
|
26
25
|
return self;
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
-(void)setCoordinates:(NSArray<
|
|
28
|
+
-(void)setCoordinates:(NSArray<AIRGoogleMapCoordinate *> *)coordinates
|
|
30
29
|
{
|
|
31
30
|
_coordinates = coordinates;
|
|
32
31
|
|
|
33
32
|
GMSMutablePath *path = [GMSMutablePath path];
|
|
34
33
|
|
|
35
|
-
if (!coordinates || coordinates.count == 0)
|
|
34
|
+
if (!coordinates || coordinates.count == 0)
|
|
36
35
|
{
|
|
37
36
|
[path removeAllCoordinates];
|
|
38
37
|
return;
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
#import <React/RCTEventDispatcher.h>
|
|
15
15
|
#import <React/RCTViewManager.h>
|
|
16
16
|
#import <React/UIView+React.h>
|
|
17
|
-
#import "RCTConvert+AirMap.h"
|
|
18
17
|
#import "AIRGoogleMapPolyline.h"
|
|
18
|
+
#import "RCTConvert+GMSMapViewType.h"
|
|
19
19
|
|
|
20
20
|
@interface AIRGoogleMapPolylineManager()
|
|
21
21
|
|
|
@@ -32,7 +32,7 @@ RCT_EXPORT_MODULE()
|
|
|
32
32
|
return polyline;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
RCT_EXPORT_VIEW_PROPERTY(coordinates,
|
|
35
|
+
RCT_EXPORT_VIEW_PROPERTY(coordinates, AIRGoogleMapCoordinateArray)
|
|
36
36
|
RCT_EXPORT_VIEW_PROPERTY(fillColor, UIColor)
|
|
37
37
|
RCT_EXPORT_VIEW_PROPERTY(strokeColor, UIColor)
|
|
38
38
|
RCT_EXPORT_VIEW_PROPERTY(strokeColors, UIColorArray)
|
|
@@ -9,9 +9,12 @@
|
|
|
9
9
|
#import <Foundation/Foundation.h>
|
|
10
10
|
#import <GoogleMaps/GoogleMaps.h>
|
|
11
11
|
#import <React/RCTConvert.h>
|
|
12
|
+
#import "AIRGoogleMapCoordinate.h"
|
|
12
13
|
|
|
13
14
|
@interface RCTConvert (GMSMapViewType)
|
|
14
15
|
+ (GMSCameraPosition*)GMSCameraPositionWithDefaults:(id)json existingCamera:(GMSCameraPosition*)existingCamera;
|
|
16
|
+
+ (NSArray<NSArray<AIRGoogleMapCoordinate *> *> *)AIRGoogleMapCoordinateArrayArray:(id)json;
|
|
17
|
+
+ (AIRGoogleMapCoordinate *)AIRGoogleMapCoordinate:(id)json;
|
|
15
18
|
@end
|
|
16
19
|
|
|
17
20
|
#endif
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
#import <GoogleMaps/GoogleMaps.h>
|
|
11
11
|
#import <React/RCTConvert.h>
|
|
12
12
|
#import <React/RCTConvert+CoreLocation.h>
|
|
13
|
+
#import "AIRGoogleMapCoordinate.h"
|
|
13
14
|
|
|
14
15
|
@implementation RCTConvert (GMSMapViewType)
|
|
15
16
|
RCT_ENUM_CONVERTER(GMSMapViewType,
|
|
@@ -30,6 +31,21 @@
|
|
|
30
31
|
return [RCTConvert GMSCameraPositionWithDefaults:json existingCamera:nil];
|
|
31
32
|
}
|
|
32
33
|
|
|
34
|
+
+ (AIRGoogleMapCoordinate *)AIRGoogleMapCoordinate:(id)json
|
|
35
|
+
{
|
|
36
|
+
AIRGoogleMapCoordinate *coord = [AIRGoogleMapCoordinate new];
|
|
37
|
+
coord.coordinate = [self CLLocationCoordinate2D:json];
|
|
38
|
+
return coord;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
RCT_ARRAY_CONVERTER(AIRGoogleMapCoordinate)
|
|
42
|
+
|
|
43
|
+
+ (NSArray<NSArray<AIRGoogleMapCoordinate *> *> *)AIRGoogleMapCoordinateArrayArray:(id)json
|
|
44
|
+
{
|
|
45
|
+
return RCTConvertArrayValue(@selector(AIRGoogleMapCoordinate:), json);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
|
|
33
49
|
+ (GMSCameraPosition*)GMSCameraPositionWithDefaults:(id)json existingCamera:(GMSCameraPosition*)existingCamera
|
|
34
50
|
{
|
|
35
51
|
CLLocationDegrees latitude = 0;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//
|
|
2
|
+
// RNMapsGoogleMapView.h
|
|
3
|
+
//
|
|
4
|
+
//
|
|
5
|
+
// Created by Salah Ghanim on 23.11.24.
|
|
6
|
+
// Copyright © 2024 react-native-maps. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
9
|
+
#ifdef HAVE_GOOGLE_MAPS
|
|
10
|
+
|
|
11
|
+
#import <React/RCTViewComponentView.h>
|
|
12
|
+
#import <UIKit/UIKit.h>
|
|
13
|
+
@class AIRGoogleMap;
|
|
14
|
+
|
|
15
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
16
|
+
|
|
17
|
+
@interface RNMapsGoogleMapView : RCTViewComponentView
|
|
18
|
+
|
|
19
|
+
- (AIRGoogleMap *) mapView;
|
|
20
|
+
|
|
21
|
+
@end
|
|
22
|
+
|
|
23
|
+
NS_ASSUME_NONNULL_END
|
|
24
|
+
|
|
25
|
+
#endif
|
|
26
|
+
#endif
|