react-native-maps 1.21.0-alpha.3 → 1.21.0-alpha.30
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 +14 -3
- 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 +166 -11
- package/ios/AirGoogleMaps/AIRGoogleMapCircle.h +0 -1
- package/ios/AirGoogleMaps/AIRGoogleMapCircle.m +20 -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 +344 -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 +29 -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 -4
- package/ios/AirMaps/AIRMap.m +226 -101
- package/ios/AirMaps/AIRMapManager.m +12 -21
- package/ios/AirMaps/AIRMapMarker.h +1 -0
- package/ios/AirMaps/AIRMapMarker.m +160 -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 +340 -334
- package/ios/AirMaps/RNMapsMarkerView.h +24 -0
- package/ios/AirMaps/RNMapsMarkerView.mm +404 -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 +3 -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 +246 -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
package/android/build.gradle
CHANGED
|
@@ -17,6 +17,19 @@ buildscript {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
def supportsNamespace() {
|
|
21
|
+
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
|
|
22
|
+
def major = parsed[0].toInteger()
|
|
23
|
+
def minor = parsed[1].toInteger()
|
|
24
|
+
|
|
25
|
+
// Namespace support was added in 7.3.0
|
|
26
|
+
if (major == 7 && minor >= 3) {
|
|
27
|
+
return true
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return major >= 8
|
|
31
|
+
}
|
|
32
|
+
|
|
20
33
|
def isNewArchitectureEnabled() {
|
|
21
34
|
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
|
|
22
35
|
}
|
|
@@ -28,9 +41,7 @@ if (isNewArchitectureEnabled()) {
|
|
|
28
41
|
apply plugin: 'kotlin-android'
|
|
29
42
|
|
|
30
43
|
android {
|
|
31
|
-
|
|
32
|
-
def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
|
|
33
|
-
if (agpVersion.tokenize('.')[0].toInteger() >= 7) {
|
|
44
|
+
if (supportsNamespace()) {
|
|
34
45
|
namespace "com.rnmaps.maps"
|
|
35
46
|
}
|
|
36
47
|
|
|
@@ -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];
|
|
@@ -303,7 +398,7 @@ id regionAsJSON(MKCoordinateRegion region) {
|
|
|
303
398
|
}
|
|
304
399
|
|
|
305
400
|
- (void)setRegion:(MKCoordinateRegion)region {
|
|
306
|
-
|
|
401
|
+
if (_isAnimating || !CLLocationCoordinate2DIsValid(region.center)) return;
|
|
307
402
|
_region = region;
|
|
308
403
|
if(_didLayoutSubviews) {
|
|
309
404
|
self.camera = [AIRGoogleMap makeGMSCameraPositionFromMap:self andMKCoordinateRegion:region];
|
|
@@ -323,6 +418,7 @@ id regionAsJSON(MKCoordinateRegion region) {
|
|
|
323
418
|
}
|
|
324
419
|
|
|
325
420
|
- (void)setCameraProp:(GMSCameraPosition*)camera {
|
|
421
|
+
if (_isAnimating || !CLLocationCoordinate2DIsValid([camera target])) return;
|
|
326
422
|
_initialCamera = camera;
|
|
327
423
|
if(_didLayoutSubviews) {
|
|
328
424
|
self.camera = camera;
|
|
@@ -404,6 +500,7 @@ id regionAsJSON(MKCoordinateRegion region) {
|
|
|
404
500
|
}
|
|
405
501
|
|
|
406
502
|
- (void)willMove:(BOOL)gesture {
|
|
503
|
+
_isAnimating = YES;
|
|
407
504
|
id event = @{@"isGesture": [NSNumber numberWithBool:gesture]};
|
|
408
505
|
if (self.onRegionChangeStart) self.onRegionChangeStart(event);
|
|
409
506
|
}
|
|
@@ -437,6 +534,7 @@ id regionAsJSON(MKCoordinateRegion region) {
|
|
|
437
534
|
@"isGesture": [NSNumber numberWithBool:isGesture],
|
|
438
535
|
};
|
|
439
536
|
if (self.onChange) self.onChange(event); // complete
|
|
537
|
+
_isAnimating = NO;
|
|
440
538
|
}
|
|
441
539
|
|
|
442
540
|
- (void)setMapPadding:(UIEdgeInsets)mapPadding {
|
|
@@ -579,11 +677,11 @@ id regionAsJSON(MKCoordinateRegion region) {
|
|
|
579
677
|
return self.settings.myLocationButton;
|
|
580
678
|
}
|
|
581
679
|
|
|
582
|
-
- (void)
|
|
680
|
+
- (void)setMinZoom:(CGFloat)minZoomLevel {
|
|
583
681
|
[self setMinZoom:minZoomLevel maxZoom:self.maxZoom ];
|
|
584
682
|
}
|
|
585
683
|
|
|
586
|
-
- (void)
|
|
684
|
+
- (void)setMaxZoom:(CGFloat)maxZoomLevel {
|
|
587
685
|
[self setMinZoom:self.minZoom maxZoom:maxZoomLevel ];
|
|
588
686
|
}
|
|
589
687
|
|
|
@@ -610,7 +708,7 @@ id regionAsJSON(MKCoordinateRegion region) {
|
|
|
610
708
|
AIRGMSMarker *airMarker = (AIRGMSMarker *) self.selectedMarker;
|
|
611
709
|
AIRGoogleMapMarker *fakeAirMarker = (AIRGoogleMapMarker *) airMarker.fakeMarker;
|
|
612
710
|
AIRGoogleMapMarker *fakeSelectedMarker = (AIRGoogleMapMarker *) selectedMarker.fakeMarker;
|
|
613
|
-
|
|
711
|
+
|
|
614
712
|
if (airMarker && airMarker.onDeselect) {
|
|
615
713
|
airMarker.onDeselect([fakeAirMarker makeEventData:@"marker-deselect"]);
|
|
616
714
|
}
|
|
@@ -618,7 +716,7 @@ id regionAsJSON(MKCoordinateRegion region) {
|
|
|
618
716
|
if (airMarker && self.onMarkerDeselect) {
|
|
619
717
|
self.onMarkerDeselect([fakeAirMarker makeEventData:@"marker-deselect"]);
|
|
620
718
|
}
|
|
621
|
-
|
|
719
|
+
|
|
622
720
|
if (selectedMarker && selectedMarker.onSelect) {
|
|
623
721
|
selectedMarker.onSelect([fakeSelectedMarker makeEventData:@"marker-select"]);
|
|
624
722
|
}
|
|
@@ -665,6 +763,63 @@ id regionAsJSON(MKCoordinateRegion region) {
|
|
|
665
763
|
return [map cameraForBounds:bounds insets:UIEdgeInsetsZero];
|
|
666
764
|
}
|
|
667
765
|
|
|
766
|
+
#pragma mark - RNMapsAirModuleDelegate
|
|
767
|
+
|
|
768
|
+
- (NSDictionary *) getCoordinatesForPoint:(CGPoint)point
|
|
769
|
+
{
|
|
770
|
+
CLLocationCoordinate2D coordinate = [self.projection coordinateForPoint:point];
|
|
771
|
+
return @{
|
|
772
|
+
@"latitude": @(coordinate.latitude),
|
|
773
|
+
@"longitude": @(coordinate.longitude),
|
|
774
|
+
};
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
- (NSDictionary *) getPointForCoordinates:(CLLocationCoordinate2D)location
|
|
778
|
+
{
|
|
779
|
+
CGPoint touchPoint = [self.projection pointForCoordinate:location];
|
|
780
|
+
return @{
|
|
781
|
+
@"x": @(touchPoint.x),
|
|
782
|
+
@"y": @(touchPoint.y),
|
|
783
|
+
};
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
-(void) takeSnapshotWithConfig:(NSDictionary *)config success:(RCTPromiseResolveBlock)success error:(RCTPromiseRejectBlock)error {
|
|
787
|
+
/* unused
|
|
788
|
+
NSNumber *width = [config objectForKey:@"width"];
|
|
789
|
+
NSNumber *height = [config objectForKey:@"height"];
|
|
790
|
+
*/
|
|
791
|
+
NSNumber *quality = [config objectForKey:@"quality"];
|
|
792
|
+
|
|
793
|
+
NSString *format = [config objectForKey:@"format"];
|
|
794
|
+
NSString *result = [config objectForKey:@"result"];
|
|
795
|
+
NSTimeInterval timeStamp = [[NSDate date] timeIntervalSince1970];
|
|
796
|
+
NSString *pathComponent = [NSString stringWithFormat:@"Documents/snapshot-%.20lf.%@", timeStamp, format];
|
|
797
|
+
NSString *filePath = [NSHomeDirectory() stringByAppendingPathComponent: pathComponent];
|
|
798
|
+
|
|
799
|
+
// TODO: currently we are ignoring width, height, region
|
|
800
|
+
|
|
801
|
+
UIGraphicsBeginImageContextWithOptions(self.frame.size, YES, 0.0f);
|
|
802
|
+
[self.layer renderInContext:UIGraphicsGetCurrentContext()];
|
|
803
|
+
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
|
|
804
|
+
|
|
805
|
+
NSData *data;
|
|
806
|
+
if ([format isEqualToString:@"png"]) {
|
|
807
|
+
data = UIImagePNGRepresentation(image);
|
|
808
|
+
|
|
809
|
+
} else if([format isEqualToString:@"jpg"]) {
|
|
810
|
+
data = UIImageJPEGRepresentation(image, quality.floatValue);
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
if ([result isEqualToString:@"file"]) {
|
|
814
|
+
[data writeToFile:filePath atomically:YES];
|
|
815
|
+
success(filePath);
|
|
816
|
+
} else if ([result isEqualToString:@"base64"]) {
|
|
817
|
+
success([data base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithCarriageReturn]);
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
UIGraphicsEndImageContext();
|
|
821
|
+
}
|
|
822
|
+
|
|
668
823
|
#pragma mark - Utils
|
|
669
824
|
|
|
670
825
|
- (CGRect) frameForMarker:(AIRGoogleMapMarker*) mrkView {
|
|
@@ -1034,7 +1189,7 @@ id regionAsJSON(MKCoordinateRegion region) {
|
|
|
1034
1189
|
}
|
|
1035
1190
|
// do nothing, passed as options on initialization
|
|
1036
1191
|
- (void)setLoadingBackgroundColor:(UIColor *)loadingBackgroundColor {
|
|
1037
|
-
|
|
1192
|
+
|
|
1038
1193
|
}
|
|
1039
1194
|
|
|
1040
1195
|
|
|
@@ -25,20 +25,29 @@
|
|
|
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
|
+
}
|
|
42
|
+
- (void) didMoveToSuperview
|
|
43
|
+
{
|
|
44
|
+
[super didMoveToSuperview];
|
|
45
|
+
[self prepare];
|
|
46
|
+
}
|
|
28
47
|
|
|
29
48
|
- (void)didMoveToWindow {
|
|
30
49
|
[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
|
-
}
|
|
50
|
+
[self prepare];
|
|
42
51
|
}
|
|
43
52
|
|
|
44
53
|
- (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;
|