react-native-maps 1.20.1 → 1.21.0-alpha.10
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/README.md +13 -6
- package/android/build.gradle +19 -4
- 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 +151 -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 +28 -119
- 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 +581 -0
- package/ios/AirGoogleMaps/RNMapsGoogleMapViewManager.mm +25 -0
- package/ios/AirMaps/AIRMap.h +8 -5
- package/ios/AirMaps/AIRMap.m +180 -27
- package/ios/AirMaps/AIRMapManager.m +24 -39
- package/ios/AirMaps/AIRMapMarker.m +11 -3
- package/ios/AirMaps/RCTConvert+AirMap.h +6 -1
- package/ios/AirMaps/RCTConvert+AirMap.m +18 -0
- package/ios/AirMaps/RNMapsAirModule.h +16 -0
- package/ios/AirMaps/RNMapsAirModule.mm +149 -0
- package/ios/AirMaps/RNMapsMapView.h +24 -0
- package/ios/AirMaps/RNMapsMapView.mm +535 -0
- package/ios/AirMaps/RNMapsMapViewManager.mm +24 -0
- package/ios/AirMaps.xcodeproj/project.pbxproj +10 -0
- package/lib/MapOverlay.d.ts +1 -1
- package/lib/MapView.d.ts +8 -4
- package/lib/MapView.js +148 -73
- package/lib/createFabricMap.d.ts +23 -0
- package/lib/createFabricMap.js +175 -0
- package/lib/specs/NativeAirMapsModule.d.ts +31 -0
- package/lib/specs/NativeAirMapsModule.js +4 -0
- package/lib/specs/NativeComponentGoogleMapView.d.ts +713 -0
- package/lib/specs/NativeComponentGoogleMapView.js +21 -0
- package/lib/specs/NativeComponentMapView.d.ts +855 -0
- package/lib/specs/NativeComponentMapView.js +21 -0
- package/package.json +14 -7
- package/react-native-maps.podspec +3 -1
- package/react-native-google-maps.podspec +0 -25
package/README.md
CHANGED
|
@@ -14,10 +14,19 @@ See [Setup Instructions for the Included Example Project](docs/examples-setup.md
|
|
|
14
14
|
|
|
15
15
|
## Compatibility
|
|
16
16
|
|
|
17
|
-
## React
|
|
17
|
+
## React Native Compatibility
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
### Important Notes:
|
|
20
|
+
|
|
21
|
+
- **Fabric is not yet supported**:
|
|
22
|
+
This feature is currently under development. Fabric is enabled by default in React Native `0.76` and above, so **please disable it** for now.
|
|
23
|
+
Follow updates on this issue here: [react-native-maps/issues/5206](https://github.com/react-native-maps/react-native-maps/issues/5206).
|
|
24
|
+
Kindly refrain from opening duplicate tickets regarding this matter.
|
|
25
|
+
|
|
26
|
+
### Version Requirements:
|
|
27
|
+
|
|
28
|
+
- **Version `1.14.0` and above**: Requires **React Native `>= 0.74`**.
|
|
29
|
+
- **Versions below `1.14.0`**: Require **React Native `>= 0.64.3`**.
|
|
21
30
|
|
|
22
31
|
## Component API
|
|
23
32
|
|
|
@@ -202,9 +211,7 @@ For IOS: configure [App Transport Security](https://developer.apple.com/library/
|
|
|
202
211
|
|
|
203
212
|
## React Native Configuration for Fabric / New Architecture
|
|
204
213
|
|
|
205
|
-
This library
|
|
206
|
-
|
|
207
|
-
There is a warning message that those steps are not necessary; but we couldn't get the example working without them so far.
|
|
214
|
+
This library doesn't support the new arch yet due to issues with inserting subviews / interoplayer. we're working on it.
|
|
208
215
|
|
|
209
216
|
### Configuration Steps
|
|
210
217
|
|
package/android/build.gradle
CHANGED
|
@@ -17,16 +17,31 @@ buildscript {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
|
|
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
|
+
}
|
|
21
32
|
|
|
22
33
|
def isNewArchitectureEnabled() {
|
|
23
34
|
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
|
|
24
35
|
}
|
|
25
36
|
|
|
37
|
+
apply plugin: 'com.android.library'
|
|
38
|
+
if (isNewArchitectureEnabled()) {
|
|
39
|
+
apply plugin: 'com.facebook.react'
|
|
40
|
+
}
|
|
41
|
+
apply plugin: 'kotlin-android'
|
|
42
|
+
|
|
26
43
|
android {
|
|
27
|
-
|
|
28
|
-
def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
|
|
29
|
-
if (agpVersion.tokenize('.')[0].toInteger() >= 7) {
|
|
44
|
+
if (supportsNamespace()) {
|
|
30
45
|
namespace "com.rnmaps.maps"
|
|
31
46
|
}
|
|
32
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
|
|
@@ -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,92 @@ id regionAsJSON(MKCoordinateRegion region) {
|
|
|
145
146
|
};
|
|
146
147
|
}
|
|
147
148
|
|
|
149
|
+
- (BOOL) isReady {
|
|
150
|
+
return _didPrepareMap;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
-(void) fitToCoordinates:(NSArray<AIRGoogleMapCoordinate *> *) coordinates withEdgePadding:(NSDictionary*) edgePadding animated:(BOOL)animated
|
|
154
|
+
{
|
|
155
|
+
CLLocationCoordinate2D myLocation = coordinates.firstObject.coordinate;
|
|
156
|
+
GMSCoordinateBounds *bounds = [[GMSCoordinateBounds alloc] initWithCoordinate:myLocation coordinate:myLocation];
|
|
157
|
+
|
|
158
|
+
for (AIRGoogleMapCoordinate *coordinate in coordinates)
|
|
159
|
+
bounds = [bounds includingCoordinate:coordinate.coordinate];
|
|
160
|
+
|
|
161
|
+
// Set Map viewport
|
|
162
|
+
CGFloat top = [RCTConvert CGFloat:edgePadding[@"top"]];
|
|
163
|
+
CGFloat right = [RCTConvert CGFloat:edgePadding[@"right"]];
|
|
164
|
+
CGFloat bottom = [RCTConvert CGFloat:edgePadding[@"bottom"]];
|
|
165
|
+
CGFloat left = [RCTConvert CGFloat:edgePadding[@"left"]];
|
|
166
|
+
|
|
167
|
+
GMSCameraUpdate *cameraUpdate = [GMSCameraUpdate fitBounds:bounds withEdgeInsets:UIEdgeInsetsMake(top, left, bottom, right)];
|
|
168
|
+
|
|
169
|
+
if (animated) {
|
|
170
|
+
[self animateWithCameraUpdate: cameraUpdate];
|
|
171
|
+
} else {
|
|
172
|
+
[self moveCamera: cameraUpdate];
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
-(void) fitToElementsWithEdgePadding:(nonnull NSDictionary *)edgePadding
|
|
177
|
+
animated:(BOOL)animated
|
|
178
|
+
{
|
|
179
|
+
CLLocationCoordinate2D myLocation = ((AIRGoogleMapMarker *)(self.markers.firstObject)).realMarker.position;
|
|
180
|
+
GMSCoordinateBounds *bounds = [[GMSCoordinateBounds alloc] initWithCoordinate:myLocation coordinate:myLocation];
|
|
181
|
+
|
|
182
|
+
for (AIRGoogleMapMarker *marker in self.markers)
|
|
183
|
+
bounds = [bounds includingCoordinate:marker.realMarker.position];
|
|
184
|
+
|
|
185
|
+
GMSCameraUpdate* cameraUpdate;
|
|
186
|
+
|
|
187
|
+
if ([edgePadding count] != 0) {
|
|
188
|
+
// Set Map viewport
|
|
189
|
+
CGFloat top = [RCTConvert CGFloat:edgePadding[@"top"]];
|
|
190
|
+
CGFloat right = [RCTConvert CGFloat:edgePadding[@"right"]];
|
|
191
|
+
CGFloat bottom = [RCTConvert CGFloat:edgePadding[@"bottom"]];
|
|
192
|
+
CGFloat left = [RCTConvert CGFloat:edgePadding[@"left"]];
|
|
193
|
+
|
|
194
|
+
cameraUpdate = [GMSCameraUpdate fitBounds:bounds withEdgeInsets:UIEdgeInsetsMake(top, left, bottom, right)];
|
|
195
|
+
} else {
|
|
196
|
+
cameraUpdate = [GMSCameraUpdate fitBounds:bounds withPadding:55.0f];
|
|
197
|
+
}
|
|
198
|
+
if (animated) {
|
|
199
|
+
[self animateWithCameraUpdate: cameraUpdate];
|
|
200
|
+
} else {
|
|
201
|
+
[self moveCamera: cameraUpdate];
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
- (void) fitToSuppliedMarkers:(NSArray*) markers withEdgePadding:(NSDictionary*) edgePadding animated:(BOOL)animated
|
|
206
|
+
{
|
|
207
|
+
NSPredicate *filterMarkers = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings) {
|
|
208
|
+
AIRGoogleMapMarker *marker = (AIRGoogleMapMarker *)evaluatedObject;
|
|
209
|
+
return [marker isKindOfClass:[AIRGoogleMapMarker class]] && [markers containsObject:marker.identifier];
|
|
210
|
+
}];
|
|
211
|
+
|
|
212
|
+
NSArray *filteredMarkers = [self.markers filteredArrayUsingPredicate:filterMarkers];
|
|
213
|
+
|
|
214
|
+
CLLocationCoordinate2D myLocation = ((AIRGoogleMapMarker *)(filteredMarkers.firstObject)).realMarker.position;
|
|
215
|
+
GMSCoordinateBounds *bounds = [[GMSCoordinateBounds alloc] initWithCoordinate:myLocation coordinate:myLocation];
|
|
216
|
+
|
|
217
|
+
for (AIRGoogleMapMarker *marker in filteredMarkers)
|
|
218
|
+
bounds = [bounds includingCoordinate:marker.realMarker.position];
|
|
219
|
+
|
|
220
|
+
// Set Map viewport
|
|
221
|
+
CGFloat top = [RCTConvert CGFloat:edgePadding[@"top"]];
|
|
222
|
+
CGFloat right = [RCTConvert CGFloat:edgePadding[@"right"]];
|
|
223
|
+
CGFloat bottom = [RCTConvert CGFloat:edgePadding[@"bottom"]];
|
|
224
|
+
CGFloat left = [RCTConvert CGFloat:edgePadding[@"left"]];
|
|
225
|
+
|
|
226
|
+
GMSCameraUpdate* cameraUpdate = [GMSCameraUpdate fitBounds:bounds withEdgeInsets:UIEdgeInsetsMake(top, left, bottom, right)];
|
|
227
|
+
if (animated) {
|
|
228
|
+
[self animateWithCameraUpdate:cameraUpdate
|
|
229
|
+
];
|
|
230
|
+
} else {
|
|
231
|
+
[self moveCamera: cameraUpdate];
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
148
235
|
#pragma clang diagnostic push
|
|
149
236
|
#pragma clang diagnostic ignored "-Wobjc-missing-super-calls"
|
|
150
237
|
- (void)insertReactSubview:(id<RCTComponent>)subview atIndex:(NSInteger)atIndex {
|
|
@@ -579,11 +666,11 @@ id regionAsJSON(MKCoordinateRegion region) {
|
|
|
579
666
|
return self.settings.myLocationButton;
|
|
580
667
|
}
|
|
581
668
|
|
|
582
|
-
- (void)
|
|
669
|
+
- (void)setMinZoom:(CGFloat)minZoomLevel {
|
|
583
670
|
[self setMinZoom:minZoomLevel maxZoom:self.maxZoom ];
|
|
584
671
|
}
|
|
585
672
|
|
|
586
|
-
- (void)
|
|
673
|
+
- (void)setMaxZoom:(CGFloat)maxZoomLevel {
|
|
587
674
|
[self setMinZoom:self.minZoom maxZoom:maxZoomLevel ];
|
|
588
675
|
}
|
|
589
676
|
|
|
@@ -610,7 +697,7 @@ id regionAsJSON(MKCoordinateRegion region) {
|
|
|
610
697
|
AIRGMSMarker *airMarker = (AIRGMSMarker *) self.selectedMarker;
|
|
611
698
|
AIRGoogleMapMarker *fakeAirMarker = (AIRGoogleMapMarker *) airMarker.fakeMarker;
|
|
612
699
|
AIRGoogleMapMarker *fakeSelectedMarker = (AIRGoogleMapMarker *) selectedMarker.fakeMarker;
|
|
613
|
-
|
|
700
|
+
|
|
614
701
|
if (airMarker && airMarker.onDeselect) {
|
|
615
702
|
airMarker.onDeselect([fakeAirMarker makeEventData:@"marker-deselect"]);
|
|
616
703
|
}
|
|
@@ -618,7 +705,7 @@ id regionAsJSON(MKCoordinateRegion region) {
|
|
|
618
705
|
if (airMarker && self.onMarkerDeselect) {
|
|
619
706
|
self.onMarkerDeselect([fakeAirMarker makeEventData:@"marker-deselect"]);
|
|
620
707
|
}
|
|
621
|
-
|
|
708
|
+
|
|
622
709
|
if (selectedMarker && selectedMarker.onSelect) {
|
|
623
710
|
selectedMarker.onSelect([fakeSelectedMarker makeEventData:@"marker-select"]);
|
|
624
711
|
}
|
|
@@ -665,6 +752,63 @@ id regionAsJSON(MKCoordinateRegion region) {
|
|
|
665
752
|
return [map cameraForBounds:bounds insets:UIEdgeInsetsZero];
|
|
666
753
|
}
|
|
667
754
|
|
|
755
|
+
#pragma mark - RNMapsAirModuleDelegate
|
|
756
|
+
|
|
757
|
+
- (NSDictionary *) getCoordinatesForPoint:(CGPoint)point
|
|
758
|
+
{
|
|
759
|
+
CLLocationCoordinate2D coordinate = [self.projection coordinateForPoint:point];
|
|
760
|
+
return @{
|
|
761
|
+
@"latitude": @(coordinate.latitude),
|
|
762
|
+
@"longitude": @(coordinate.longitude),
|
|
763
|
+
};
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
- (NSDictionary *) getPointForCoordinates:(CLLocationCoordinate2D)location
|
|
767
|
+
{
|
|
768
|
+
CGPoint touchPoint = [self.projection pointForCoordinate:location];
|
|
769
|
+
return @{
|
|
770
|
+
@"x": @(touchPoint.x),
|
|
771
|
+
@"y": @(touchPoint.y),
|
|
772
|
+
};
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
-(void) takeSnapshotWithConfig:(NSDictionary *)config callback:(RCTPromiseResolveBlock) callback
|
|
776
|
+
{
|
|
777
|
+
/* unused
|
|
778
|
+
NSNumber *width = [config objectForKey:@"width"];
|
|
779
|
+
NSNumber *height = [config objectForKey:@"height"];
|
|
780
|
+
*/
|
|
781
|
+
NSNumber *quality = [config objectForKey:@"quality"];
|
|
782
|
+
|
|
783
|
+
NSString *format = [config objectForKey:@"format"];
|
|
784
|
+
NSString *result = [config objectForKey:@"result"];
|
|
785
|
+
NSString *filePath = [config objectForKey:@"filePath"];
|
|
786
|
+
|
|
787
|
+
|
|
788
|
+
// TODO: currently we are ignoring width, height, region
|
|
789
|
+
|
|
790
|
+
UIGraphicsBeginImageContextWithOptions(self.frame.size, YES, 0.0f);
|
|
791
|
+
[self.layer renderInContext:UIGraphicsGetCurrentContext()];
|
|
792
|
+
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
|
|
793
|
+
|
|
794
|
+
NSData *data;
|
|
795
|
+
if ([format isEqualToString:@"png"]) {
|
|
796
|
+
data = UIImagePNGRepresentation(image);
|
|
797
|
+
|
|
798
|
+
} else if([format isEqualToString:@"jpg"]) {
|
|
799
|
+
data = UIImageJPEGRepresentation(image, quality.floatValue);
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
if ([result isEqualToString:@"file"]) {
|
|
803
|
+
[data writeToFile:filePath atomically:YES];
|
|
804
|
+
callback(filePath);
|
|
805
|
+
} else if ([result isEqualToString:@"base64"]) {
|
|
806
|
+
callback([data base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithCarriageReturn]);
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
UIGraphicsEndImageContext();
|
|
810
|
+
}
|
|
811
|
+
|
|
668
812
|
#pragma mark - Utils
|
|
669
813
|
|
|
670
814
|
- (CGRect) frameForMarker:(AIRGoogleMapMarker*) mrkView {
|
|
@@ -1034,7 +1178,7 @@ id regionAsJSON(MKCoordinateRegion region) {
|
|
|
1034
1178
|
}
|
|
1035
1179
|
// do nothing, passed as options on initialization
|
|
1036
1180
|
- (void)setLoadingBackgroundColor:(UIColor *)loadingBackgroundColor {
|
|
1037
|
-
|
|
1181
|
+
|
|
1038
1182
|
}
|
|
1039
1183
|
|
|
1040
1184
|
|
|
@@ -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;
|