react-native-maps 1.21.0-alpha.4 → 1.21.0-alpha.40
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/src/main/java/com/rnmaps/fabric/NativeAirMapsModule.java +51 -0
- package/android/src/main/java/com/rnmaps/maps/MapAirModulePackage.java +46 -0
- package/ios/AirGoogleMaps/AIRGoogleMap.h +8 -2
- package/ios/AirGoogleMaps/AIRGoogleMap.m +179 -11
- 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 +599 -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 +284 -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 +3 -0
- 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 +341 -334
- package/ios/AirMaps/RNMapsMarkerView.h +24 -0
- package/ios/AirMaps/RNMapsMarkerView.mm +422 -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/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/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 +7 -7
- package/react-native-maps.podspec +1 -1
- package/lib/FabricMapView.js +0 -175
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
package com.rnmaps.fabric;
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.Promise;
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
5
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
6
|
+
|
|
7
|
+
public class NativeAirMapsModule extends NativeAirMapsModuleSpec {
|
|
8
|
+
public NativeAirMapsModule(ReactApplicationContext reactContext) {
|
|
9
|
+
super(reactContext);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
@Override
|
|
13
|
+
public String getName() {
|
|
14
|
+
return NAME;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@Override
|
|
18
|
+
public void getCamera(double tag, Promise promise) {
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@Override
|
|
23
|
+
public void getMarkersFrames(double tag, boolean onlyVisible, Promise promise) {
|
|
24
|
+
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@Override
|
|
28
|
+
public void getMapBoundaries(double tag, Promise promise) {
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@Override
|
|
33
|
+
public void takeSnapshot(double tag, ReadableMap config, Promise promise) {
|
|
34
|
+
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@Override
|
|
38
|
+
public void getAddressFromCoordinates(double tag, ReadableMap coordinate, Promise promise) {
|
|
39
|
+
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@Override
|
|
43
|
+
public void getPointForCoordinate(double tag, ReadableMap coordinate, Promise promise) {
|
|
44
|
+
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@Override
|
|
48
|
+
public void getCoordinateForPoint(double tag, ReadableMap point, Promise promise) {
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
package com.rnmaps.maps;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
|
|
5
|
+
import com.facebook.react.TurboReactPackage;
|
|
6
|
+
import com.facebook.react.bridge.NativeModule;
|
|
7
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
8
|
+
import com.facebook.react.module.model.ReactModuleInfo;
|
|
9
|
+
import com.facebook.react.module.model.ReactModuleInfoProvider;
|
|
10
|
+
import com.rnmaps.fabric.NativeAirMapsModule;
|
|
11
|
+
import com.rnmaps.fabric.NativeAirMapsModuleSpec;
|
|
12
|
+
|
|
13
|
+
import java.util.HashMap;
|
|
14
|
+
import java.util.Map;
|
|
15
|
+
|
|
16
|
+
public class MapAirModulePackage extends TurboReactPackage {
|
|
17
|
+
|
|
18
|
+
@Override
|
|
19
|
+
public NativeModule getModule(String name, ReactApplicationContext reactContext) {
|
|
20
|
+
if (name.equals(NativeAirMapsModuleSpec.NAME)) {
|
|
21
|
+
return new NativeAirMapsModule(reactContext);
|
|
22
|
+
} else {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@Override
|
|
28
|
+
public ReactModuleInfoProvider getReactModuleInfoProvider() {
|
|
29
|
+
return new ReactModuleInfoProvider() {
|
|
30
|
+
@NonNull
|
|
31
|
+
@Override
|
|
32
|
+
public Map<String, ReactModuleInfo> getReactModuleInfos() {
|
|
33
|
+
Map<String, ReactModuleInfo> map = new HashMap<>();
|
|
34
|
+
map.put(NativeAirMapsModuleSpec.NAME, new ReactModuleInfo(
|
|
35
|
+
NativeAirMapsModuleSpec.NAME, // name
|
|
36
|
+
NativeAirMapsModuleSpec.NAME, // className
|
|
37
|
+
false, // canOverrideExistingModule
|
|
38
|
+
false, // needsEagerInit
|
|
39
|
+
false, // isCXXModule
|
|
40
|
+
true // isTurboModule
|
|
41
|
+
));
|
|
42
|
+
return map;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -13,9 +13,10 @@
|
|
|
13
13
|
#import <GoogleMaps/GoogleMaps.h>
|
|
14
14
|
#import <MapKit/MapKit.h>
|
|
15
15
|
#import "AIRGMSMarker.h"
|
|
16
|
-
#import "
|
|
16
|
+
#import "RNMapsAirModuleDelegate.h"
|
|
17
|
+
#import "AIRGoogleMapCoordinate.h"
|
|
17
18
|
|
|
18
|
-
@interface AIRGoogleMap : GMSMapView
|
|
19
|
+
@interface AIRGoogleMap : GMSMapView <RNMapsAirModuleDelegate>
|
|
19
20
|
|
|
20
21
|
// TODO: don't use MK region?
|
|
21
22
|
@property (nonatomic, weak) RCTBridge *bridge;
|
|
@@ -66,6 +67,7 @@
|
|
|
66
67
|
@property (nonatomic, assign) BOOL showsIndoorLevelPicker;
|
|
67
68
|
@property (nonatomic, assign) NSString *kmlSrc;
|
|
68
69
|
|
|
70
|
+
- (BOOL) isReady;
|
|
69
71
|
- (void)didPrepareMap;
|
|
70
72
|
- (void)mapViewDidFinishTileRendering;
|
|
71
73
|
- (BOOL)didTapMarker:(GMSMarker *)marker;
|
|
@@ -84,6 +86,10 @@
|
|
|
84
86
|
|
|
85
87
|
- (NSDictionary*) getMarkersFramesWithOnlyVisible:(BOOL)onlyVisible;
|
|
86
88
|
- (instancetype)initWithMapId:(NSString *)mapId initialCamera:(GMSCameraPosition*) camera backgroundColor:(UIColor *) backgroundColor andZoomTapEnabled:(BOOL)zoomTapEnabled;
|
|
89
|
+
-(void) fitToSuppliedMarkers:(NSArray*) markers withEdgePadding:(NSDictionary*) edgePadding animated:(BOOL)animated;
|
|
90
|
+
-(void) fitToCoordinates:(NSArray<AIRGoogleMapCoordinate *> *) coordinates withEdgePadding:(NSDictionary*) edgePadding animated:(BOOL)animated;
|
|
91
|
+
-(void) fitToElementsWithEdgePadding:(nonnull NSDictionary *)edgePadding
|
|
92
|
+
animated:(BOOL)animated;
|
|
87
93
|
@end
|
|
88
94
|
|
|
89
95
|
#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
|
|
@@ -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 {
|
|
@@ -1034,7 +1202,7 @@ id regionAsJSON(MKCoordinateRegion region) {
|
|
|
1034
1202
|
}
|
|
1035
1203
|
// do nothing, passed as options on initialization
|
|
1036
1204
|
- (void)setLoadingBackgroundColor:(UIColor *)loadingBackgroundColor {
|
|
1037
|
-
|
|
1205
|
+
|
|
1038
1206
|
}
|
|
1039
1207
|
|
|
1040
1208
|
|
|
@@ -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;
|