react-native-maps 1.21.0-alpha.12 → 1.21.0-alpha.13
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.m +6 -2
- package/ios/AirGoogleMaps/AIRGoogleMapMarker.m +9 -4
- package/ios/AirGoogleMaps/AIRGoogleMapPolygon.h +2 -1
- package/ios/AirGoogleMaps/AIRGoogleMapPolygon.m +27 -0
- package/ios/AirGoogleMaps/RCTConvert+GMSMapViewType.m +2 -0
- package/ios/AirGoogleMaps/RNMapsGoogleMapView.mm +15 -19
- package/ios/AirMaps/AIRMap.h +1 -0
- package/ios/AirMaps/AIRMap.m +8 -0
- package/ios/AirMaps/AIRMapManager.m +3 -0
- package/ios/AirMaps/RNMapsMapView.mm +351 -338
- package/package.json +1 -1
|
@@ -69,6 +69,7 @@ id regionAsJSON(MKCoordinateRegion region) {
|
|
|
69
69
|
BOOL _didPrepareMap;
|
|
70
70
|
BOOL _didCallOnMapReady;
|
|
71
71
|
BOOL _zoomTapEnabled;
|
|
72
|
+
BOOL _isAnimating;
|
|
72
73
|
NSString* _googleMapId;
|
|
73
74
|
}
|
|
74
75
|
|
|
@@ -243,7 +244,7 @@ id regionAsJSON(MKCoordinateRegion region) {
|
|
|
243
244
|
[self.markers addObject:marker];
|
|
244
245
|
} else if ([subview isKindOfClass:[AIRGoogleMapPolygon class]]) {
|
|
245
246
|
AIRGoogleMapPolygon *polygon = (AIRGoogleMapPolygon*)subview;
|
|
246
|
-
polygon
|
|
247
|
+
[polygon didInsertInMap:self];
|
|
247
248
|
[self.polygons addObject:polygon];
|
|
248
249
|
} else if ([subview isKindOfClass:[AIRGoogleMapPolyline class]]) {
|
|
249
250
|
AIRGoogleMapPolyline *polyline = (AIRGoogleMapPolyline*)subview;
|
|
@@ -390,7 +391,7 @@ id regionAsJSON(MKCoordinateRegion region) {
|
|
|
390
391
|
}
|
|
391
392
|
|
|
392
393
|
- (void)setRegion:(MKCoordinateRegion)region {
|
|
393
|
-
|
|
394
|
+
if (_isAnimating || !CLLocationCoordinate2DIsValid(region.center)) return;
|
|
394
395
|
_region = region;
|
|
395
396
|
if(_didLayoutSubviews) {
|
|
396
397
|
self.camera = [AIRGoogleMap makeGMSCameraPositionFromMap:self andMKCoordinateRegion:region];
|
|
@@ -410,6 +411,7 @@ id regionAsJSON(MKCoordinateRegion region) {
|
|
|
410
411
|
}
|
|
411
412
|
|
|
412
413
|
- (void)setCameraProp:(GMSCameraPosition*)camera {
|
|
414
|
+
if (_isAnimating || !CLLocationCoordinate2DIsValid([camera target])) return;
|
|
413
415
|
_initialCamera = camera;
|
|
414
416
|
if(_didLayoutSubviews) {
|
|
415
417
|
self.camera = camera;
|
|
@@ -491,6 +493,7 @@ id regionAsJSON(MKCoordinateRegion region) {
|
|
|
491
493
|
}
|
|
492
494
|
|
|
493
495
|
- (void)willMove:(BOOL)gesture {
|
|
496
|
+
_isAnimating = YES;
|
|
494
497
|
id event = @{@"isGesture": [NSNumber numberWithBool:gesture]};
|
|
495
498
|
if (self.onRegionChangeStart) self.onRegionChangeStart(event);
|
|
496
499
|
}
|
|
@@ -524,6 +527,7 @@ id regionAsJSON(MKCoordinateRegion region) {
|
|
|
524
527
|
@"isGesture": [NSNumber numberWithBool:isGesture],
|
|
525
528
|
};
|
|
526
529
|
if (self.onChange) self.onChange(event); // complete
|
|
530
|
+
_isAnimating = NO;
|
|
527
531
|
}
|
|
528
532
|
|
|
529
533
|
- (void)setMapPadding:(UIEdgeInsets)mapPadding {
|
|
@@ -359,6 +359,7 @@ CGRect unionRect(CGRect a, CGRect b) {
|
|
|
359
359
|
_iconImageView = empyImageView;
|
|
360
360
|
[self iconViewInsertSubview:_iconImageView atIndex:0];
|
|
361
361
|
}
|
|
362
|
+
__weak AIRGoogleMapMarker* weakSelf = self;
|
|
362
363
|
|
|
363
364
|
_reloadImageCancellationBlock = [[_bridge moduleForName:@"ImageLoader"] loadImageWithURLRequest:[RCTConvert NSURLRequest:_imageSrc]
|
|
364
365
|
size:self.bounds.size
|
|
@@ -372,10 +373,12 @@ CGRect unionRect(CGRect a, CGRect b) {
|
|
|
372
373
|
// TODO(lmr): do something with the error?
|
|
373
374
|
NSLog(@"%@", error);
|
|
374
375
|
}
|
|
376
|
+
|
|
375
377
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
378
|
+
__strong AIRGoogleMapMarker* strongSelf = weakSelf;
|
|
376
379
|
|
|
377
380
|
// TODO(gil): This way allows different image sizes
|
|
378
|
-
if (
|
|
381
|
+
if (strongSelf->_iconImageView) [strongSelf->_iconImageView removeFromSuperview];
|
|
379
382
|
|
|
380
383
|
// ... but this way is more efficient?
|
|
381
384
|
// if (_iconImageView) {
|
|
@@ -399,10 +402,12 @@ CGRect unionRect(CGRect a, CGRect b) {
|
|
|
399
402
|
// when the image loads IF the image is larger than the UIView.
|
|
400
403
|
// Shouldn't required images have size info automatically via RN?
|
|
401
404
|
CGRect selfBounds = unionRect(bounds, self.bounds);
|
|
402
|
-
[
|
|
405
|
+
[strongSelf setFrame:selfBounds];
|
|
403
406
|
|
|
404
|
-
|
|
405
|
-
[
|
|
407
|
+
strongSelf->_iconImageView = imageView;
|
|
408
|
+
[strongSelf iconViewInsertSubview:imageView atIndex:0];
|
|
409
|
+
[strongSelf layoutSubviews];
|
|
410
|
+
[strongSelf.realMarker setIconView:strongSelf.iconView];
|
|
406
411
|
});
|
|
407
412
|
}];
|
|
408
413
|
}
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
#import <React/RCTBridge.h>
|
|
11
11
|
#import "AIRGMSPolygon.h"
|
|
12
12
|
#import "AIRGoogleMapCoordinate.h"
|
|
13
|
+
#import "AIRGoogleMap.h"
|
|
13
14
|
|
|
14
15
|
@interface AIRGoogleMapPolygon : UIView
|
|
15
16
|
|
|
@@ -26,7 +27,7 @@
|
|
|
26
27
|
@property (nonatomic, assign) BOOL geodesic;
|
|
27
28
|
@property (nonatomic, assign) int zIndex;
|
|
28
29
|
@property (nonatomic, assign) BOOL tappable;
|
|
29
|
-
|
|
30
|
+
- (void) didInsertInMap:(AIRGoogleMap *) map;
|
|
30
31
|
@end
|
|
31
32
|
|
|
32
33
|
#endif
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
#import "AIRGoogleMapPolygon.h"
|
|
10
10
|
#import "AIRGMSPolygon.h"
|
|
11
11
|
#import <GoogleMaps/GoogleMaps.h>
|
|
12
|
+
#import "AIRGoogleMap.h"
|
|
12
13
|
|
|
13
14
|
@implementation AIRGoogleMapPolygon
|
|
14
15
|
{
|
|
@@ -41,6 +42,32 @@
|
|
|
41
42
|
_polygon.strokeWidth = _strokeWidth;
|
|
42
43
|
}
|
|
43
44
|
}
|
|
45
|
+
- (void) didInsertInMap:(AIRGoogleMap *) map
|
|
46
|
+
{
|
|
47
|
+
_polygon = [AIRGMSPolygon new];
|
|
48
|
+
|
|
49
|
+
if (_identifier){
|
|
50
|
+
[_polygon setIdentifier:_identifier];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
[_polygon setTappable:_tappable];
|
|
54
|
+
if (_strokeColor){
|
|
55
|
+
_polygon.strokeColor = _strokeColor;
|
|
56
|
+
}
|
|
57
|
+
if (_fillColor){
|
|
58
|
+
_polygon.fillColor = _fillColor;
|
|
59
|
+
}
|
|
60
|
+
if (_strokeWidth){
|
|
61
|
+
_polygon.strokeWidth = _strokeWidth;
|
|
62
|
+
}
|
|
63
|
+
if (_coordinates){
|
|
64
|
+
[self setCoordinates:_coordinates];
|
|
65
|
+
}
|
|
66
|
+
if (_holes){
|
|
67
|
+
[self setHoles:_holes];
|
|
68
|
+
}
|
|
69
|
+
[_polygon setMap:map];
|
|
70
|
+
}
|
|
44
71
|
|
|
45
72
|
- (void)setCoordinates:(NSArray<AIRGoogleMapCoordinate *> *)coordinates
|
|
46
73
|
{
|
|
@@ -33,6 +33,8 @@
|
|
|
33
33
|
|
|
34
34
|
+ (AIRGoogleMapCoordinate *)AIRGoogleMapCoordinate:(id)json
|
|
35
35
|
{
|
|
36
|
+
// empty coordinates
|
|
37
|
+
if ([json isKindOfClass:[NSArray class]] && [json count] == 0) return nil;
|
|
36
38
|
AIRGoogleMapCoordinate *coord = [AIRGoogleMapCoordinate new];
|
|
37
39
|
coord.coordinate = [self CLLocationCoordinate2D:json];
|
|
38
40
|
return coord;
|
|
@@ -43,11 +43,8 @@ using namespace facebook::react;
|
|
|
43
43
|
- (void)animateToRegion:(NSString *)regionJSON duration:(NSInteger)duration{
|
|
44
44
|
NSDictionary* regionDic = [RCTConvert dictonaryFromString:regionJSON];
|
|
45
45
|
MKCoordinateRegion region = [RCTConvert MKCoordinateRegion:regionDic];
|
|
46
|
-
[CATransaction begin];
|
|
47
|
-
[CATransaction setAnimationDuration:duration/1000];
|
|
48
46
|
GMSCameraPosition *camera = [AIRGoogleMap makeGMSCameraPositionFromMap:_view andMKCoordinateRegion:region];
|
|
49
|
-
[
|
|
50
|
-
[CATransaction commit];
|
|
47
|
+
[_view animateToCameraPosition:camera];
|
|
51
48
|
}
|
|
52
49
|
- (void)setCamera:(NSString *)cameraJSON{
|
|
53
50
|
NSDictionary* cameraDic = [RCTConvert dictonaryFromString:cameraJSON];
|
|
@@ -489,20 +486,6 @@ using namespace facebook::react;
|
|
|
489
486
|
_view.name = region; \
|
|
490
487
|
}
|
|
491
488
|
|
|
492
|
-
#define REMAP_GOOGLEMAPVIEW_CAMERA_PROP(name) \
|
|
493
|
-
if (newViewProps.name.center.latitude != oldViewProps.name.center.latitude || \
|
|
494
|
-
newViewProps.name.center.longitude != oldViewProps.name.center.longitude || \
|
|
495
|
-
newViewProps.name.heading != oldViewProps.name.heading || \
|
|
496
|
-
newViewProps.name.pitch != oldViewProps.name.pitch || \
|
|
497
|
-
newViewProps.name.zoom != oldViewProps.name.zoom) { \
|
|
498
|
-
GMSCameraPosition* camera = [GMSCameraPosition cameraWithLatitude:newViewProps.name.center.latitude \
|
|
499
|
-
longitude:newViewProps.name.center.longitude \
|
|
500
|
-
zoom:newViewProps.name.zoom \
|
|
501
|
-
bearing:newViewProps.name.heading \
|
|
502
|
-
viewingAngle:newViewProps.name.pitch]; \
|
|
503
|
-
_view.name = camera; \
|
|
504
|
-
}
|
|
505
|
-
|
|
506
489
|
|
|
507
490
|
#define REMAP_MAPVIEW_EDGEINSETS_PROP(name) \
|
|
508
491
|
if (newViewProps.name.top != oldViewProps.name.top || \
|
|
@@ -535,7 +518,18 @@ using namespace facebook::react;
|
|
|
535
518
|
REMAP_MAPVIEW_REGION_PROP(region)
|
|
536
519
|
REMAP_MAPVIEW_REGION_PROP(initialRegion)
|
|
537
520
|
|
|
538
|
-
|
|
521
|
+
if (newViewProps.camera.center.latitude != oldViewProps.camera.center.latitude ||
|
|
522
|
+
newViewProps.camera.center.longitude != oldViewProps.camera.center.longitude ||
|
|
523
|
+
newViewProps.camera.heading != oldViewProps.camera.heading ||
|
|
524
|
+
newViewProps.camera.pitch != oldViewProps.camera.pitch ||
|
|
525
|
+
newViewProps.camera.zoom != oldViewProps.camera.zoom) {
|
|
526
|
+
GMSCameraPosition* camera = [GMSCameraPosition cameraWithLatitude:newViewProps.camera.center.latitude
|
|
527
|
+
longitude:newViewProps.camera.center.longitude
|
|
528
|
+
zoom:newViewProps.camera.zoom
|
|
529
|
+
bearing:newViewProps.camera.heading
|
|
530
|
+
viewingAngle:newViewProps.camera.pitch];
|
|
531
|
+
_view.cameraProp = camera;
|
|
532
|
+
}
|
|
539
533
|
|
|
540
534
|
|
|
541
535
|
REMAP_MAPVIEW_EDGEINSETS_PROP(mapPadding)
|
|
@@ -551,8 +545,10 @@ using namespace facebook::react;
|
|
|
551
545
|
break;
|
|
552
546
|
case RNMapsGoogleMapViewMapType::Terrain:
|
|
553
547
|
_view.mapType = kGMSTypeTerrain;
|
|
548
|
+
break;
|
|
554
549
|
case RNMapsGoogleMapViewMapType::Hybrid:
|
|
555
550
|
_view.mapType = kGMSTypeHybrid;
|
|
551
|
+
break;
|
|
556
552
|
default:
|
|
557
553
|
_view.mapType = kGMSTypeNormal;
|
|
558
554
|
break;
|
package/ios/AirMaps/AIRMap.h
CHANGED
package/ios/AirMaps/AIRMap.m
CHANGED
|
@@ -52,6 +52,7 @@ const NSInteger AIRMapMaxZoomLevel = 20;
|
|
|
52
52
|
UIView *_legalLabel;
|
|
53
53
|
BOOL _initialRegionSet;
|
|
54
54
|
BOOL _initialCameraSet;
|
|
55
|
+
BOOL _initialized;
|
|
55
56
|
|
|
56
57
|
// Array to manually track RN subviews
|
|
57
58
|
//
|
|
@@ -90,6 +91,7 @@ const NSInteger AIRMapMaxZoomLevel = 20;
|
|
|
90
91
|
self.maxZoom = AIRMapMaxZoomLevel;
|
|
91
92
|
self.compassOffset = CGPointMake(0, 0);
|
|
92
93
|
self.legacyZoomConstraintsEnabled = YES;
|
|
94
|
+
_initialized = YES;
|
|
93
95
|
}
|
|
94
96
|
return self;
|
|
95
97
|
}
|
|
@@ -101,6 +103,9 @@ const NSInteger AIRMapMaxZoomLevel = 20;
|
|
|
101
103
|
[super addSubview:view];
|
|
102
104
|
}
|
|
103
105
|
}
|
|
106
|
+
- (void) didSetRegion {
|
|
107
|
+
_initialRegionSet = YES;
|
|
108
|
+
}
|
|
104
109
|
|
|
105
110
|
#pragma clang diagnostic push
|
|
106
111
|
#pragma clang diagnostic ignored "-Wobjc-missing-super-calls"
|
|
@@ -562,6 +567,9 @@ MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coords count:coordina
|
|
|
562
567
|
}
|
|
563
568
|
|
|
564
569
|
- (void)setInitialRegion:(MKCoordinateRegion)initialRegion {
|
|
570
|
+
if (!CLLocationCoordinate2DIsValid(initialRegion.center)) {
|
|
571
|
+
return;
|
|
572
|
+
}
|
|
565
573
|
if (!_initialRegionSet) {
|
|
566
574
|
_initialRegionSet = YES;
|
|
567
575
|
[self setRegion:initialRegion animated:NO];
|
|
@@ -951,6 +951,8 @@ static int kDragCenterContext;
|
|
|
951
951
|
|
|
952
952
|
mapView.pendingCenter = mapView.region.center;
|
|
953
953
|
mapView.pendingSpan = mapView.region.span;
|
|
954
|
+
// reset original state (checkout setCamera / region animated)
|
|
955
|
+
mapView.ignoreRegionChanges = NO;
|
|
954
956
|
}
|
|
955
957
|
|
|
956
958
|
- (void)mapViewWillStartRenderingMap:(AIRMap *)mapView
|
|
@@ -965,6 +967,7 @@ static int kDragCenterContext;
|
|
|
965
967
|
- (void)mapViewDidFinishRenderingMap:(AIRMap *)mapView fullyRendered:(BOOL)fullyRendered
|
|
966
968
|
{
|
|
967
969
|
[mapView finishLoading];
|
|
970
|
+
mapView.ignoreRegionChanges = NO;
|
|
968
971
|
}
|
|
969
972
|
|
|
970
973
|
#pragma mark Private
|
|
@@ -33,12 +33,21 @@ using namespace facebook::react;
|
|
|
33
33
|
return _view;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
- (void) prepareForRecycle
|
|
37
|
+
{
|
|
38
|
+
[super prepareForRecycle];
|
|
39
|
+
[_view removeFromSuperview];
|
|
40
|
+
_view = nil;
|
|
41
|
+
_legacyMapManager = nil;
|
|
42
|
+
self.contentView = nil;
|
|
43
|
+
}
|
|
44
|
+
|
|
36
45
|
#pragma mark - JS Commands
|
|
37
46
|
- (void)animateToRegion:(NSString *)regionJSON duration:(NSInteger)duration{
|
|
38
47
|
NSDictionary* regionDic = [RCTConvert dictonaryFromString:regionJSON];
|
|
39
|
-
[
|
|
40
|
-
|
|
41
|
-
|
|
48
|
+
MKCoordinateRegion region = [RCTConvert MKCoordinateRegion:regionDic];
|
|
49
|
+
_view.ignoreRegionChanges = YES;
|
|
50
|
+
[_view setRegion:region animated:YES];
|
|
42
51
|
}
|
|
43
52
|
- (void)setCamera:(NSString *)cameraJSON{
|
|
44
53
|
NSDictionary* cameraDic = [RCTConvert dictonaryFromString:cameraJSON];
|
|
@@ -49,16 +58,9 @@ using namespace facebook::react;
|
|
|
49
58
|
- (void)animateCamera:(NSString *)cameraJSON duration:(NSInteger)duration{
|
|
50
59
|
NSDictionary* cameraDic = [RCTConvert dictonaryFromString:cameraJSON];
|
|
51
60
|
MKMapCamera *camera = [RCTConvert MKMapCameraWithDefaults:cameraDic existingCamera:[_view camera]];
|
|
52
|
-
|
|
53
61
|
// don't emit region change events when we are setting the camera
|
|
54
|
-
BOOL originalIgnore = _view.ignoreRegionChanges;
|
|
55
62
|
_view.ignoreRegionChanges = YES;
|
|
56
|
-
[
|
|
57
|
-
[self->_view setCamera:camera animated:YES];
|
|
58
|
-
} completion:^(BOOL finished){
|
|
59
|
-
self->_view.ignoreRegionChanges = originalIgnore;
|
|
60
|
-
}];
|
|
61
|
-
|
|
63
|
+
[_view setCamera:camera animated:YES];
|
|
62
64
|
}
|
|
63
65
|
|
|
64
66
|
- (void)fitToElements:(NSString *)edgePaddingJSON animated:(BOOL)animated {
|
|
@@ -73,7 +75,6 @@ using namespace facebook::react;
|
|
|
73
75
|
}];
|
|
74
76
|
NSArray *filteredMarkers = [_view.annotations filteredArrayUsingPredicate:filterMarkers];
|
|
75
77
|
[_view showAnnotations:filteredMarkers animated:animated];
|
|
76
|
-
|
|
77
78
|
}
|
|
78
79
|
- (void)fitToCoordinates:(NSString *)coordinatesJSON edgePaddingJSON:(NSString *)edgePaddingJSON animated:(BOOL)animated {
|
|
79
80
|
NSArray* coordinatesArr = [RCTConvert arrayFromString:coordinatesJSON];
|
|
@@ -81,12 +82,12 @@ using namespace facebook::react;
|
|
|
81
82
|
for (id json : coordinatesArr){
|
|
82
83
|
[mutableArray addObject:[RCTConvert AIRMapCoordinate:json]];
|
|
83
84
|
}
|
|
84
|
-
|
|
85
|
+
|
|
85
86
|
NSDictionary* edgePadding = [RCTConvert dictonaryFromString:edgePaddingJSON];
|
|
86
|
-
|
|
87
|
+
|
|
87
88
|
UIEdgeInsets edgeInsets = [RCTConvert UIEdgeInsets:edgePadding];
|
|
88
89
|
[_view fitToCoordinates:mutableArray edgePadding:edgeInsets animated:animated];
|
|
89
|
-
|
|
90
|
+
|
|
90
91
|
}
|
|
91
92
|
|
|
92
93
|
#pragma mark - Native commands
|
|
@@ -99,264 +100,270 @@ using namespace facebook::react;
|
|
|
99
100
|
|
|
100
101
|
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
101
102
|
{
|
|
102
|
-
|
|
103
|
+
return concreteComponentDescriptorProvider<RNMapsMapViewComponentDescriptor>();
|
|
103
104
|
}
|
|
104
105
|
|
|
105
|
-
|
|
106
|
-
- (instancetype)initWithFrame:(CGRect)frame
|
|
106
|
+
- (void) prepareMapView
|
|
107
107
|
{
|
|
108
|
-
|
|
108
|
+
if (_legacyMapManager && _view) return;
|
|
109
109
|
static const auto defaultProps = std::make_shared<const RNMapsMapViewProps>();
|
|
110
110
|
_props = defaultProps;
|
|
111
|
-
|
|
111
|
+
_legacyMapManager = [[AIRMapManager alloc] init];
|
|
112
112
|
_view = (AIRMap *)[_legacyMapManager view];
|
|
113
|
-
|
|
113
|
+
|
|
114
114
|
self.contentView = _view;
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
115
|
+
|
|
116
|
+
_view.onPress = [self](NSDictionary* dictionary) {
|
|
117
|
+
if (_eventEmitter) {
|
|
118
|
+
// Extract values from the NSDictionary
|
|
119
|
+
NSDictionary* coordinateDict = dictionary[@"coordinate"];
|
|
120
|
+
NSDictionary* positionDict = dictionary[@"position"];
|
|
121
|
+
|
|
122
|
+
// Populate the OnMapPressCoordinate struct
|
|
123
|
+
facebook::react::RNMapsMapViewEventEmitter::OnPressCoordinate coordinate = {
|
|
124
|
+
.latitude = [coordinateDict[@"latitude"] doubleValue],
|
|
125
|
+
.longitude = [coordinateDict[@"longitude"] doubleValue],
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
// Populate the OnMapPressPosition struct
|
|
129
|
+
facebook::react::RNMapsMapViewEventEmitter::OnPressPosition position = {
|
|
130
|
+
.x = [positionDict[@"x"] doubleValue],
|
|
131
|
+
.y = [positionDict[@"y"] doubleValue],
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
|
|
135
|
+
facebook::react::RNMapsMapViewEventEmitter::OnPress data = {
|
|
136
|
+
.action = std::string([@"press" UTF8String]),
|
|
137
|
+
.position = position,
|
|
138
|
+
.coordinate = coordinate
|
|
139
|
+
};
|
|
140
|
+
mapViewEventEmitter->onPress(data);
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
_view.onMapReady = [self](NSDictionary* dictionary) {
|
|
146
|
+
if (_eventEmitter) {
|
|
147
|
+
|
|
148
|
+
auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
|
|
149
|
+
facebook::react::RNMapsMapViewEventEmitter::OnMapReady data = {};
|
|
150
|
+
mapViewEventEmitter->onMapReady(data);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
_view.onChange = [self](NSDictionary* dictionary) {
|
|
154
|
+
if (_eventEmitter) {
|
|
155
|
+
|
|
156
|
+
NSDictionary* regionDict = dictionary[@"region"];
|
|
157
|
+
auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
|
|
158
|
+
facebook::react::RNMapsMapViewEventEmitter::OnRegionChange data = {
|
|
159
|
+
.region.latitude = [regionDict[@"latitude"] doubleValue],
|
|
160
|
+
.region.longitude = [regionDict[@"longitude"] doubleValue],
|
|
161
|
+
.region.latitudeDelta = [regionDict[@"latitudeDelta"] doubleValue],
|
|
162
|
+
.region.longitudeDelta = [regionDict[@"longitudeDelta"] doubleValue],
|
|
163
|
+
.continuous = [dictionary[@"continuous"] boolValue],
|
|
164
|
+
};
|
|
165
|
+
mapViewEventEmitter->onRegionChange(data);
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
_view.onDoublePress = [self](NSDictionary* dictionary) {
|
|
169
|
+
if (_eventEmitter) {
|
|
170
|
+
|
|
171
|
+
NSDictionary* coordinateDict = dictionary[@"coordinate"];
|
|
172
|
+
NSDictionary* positionDict = dictionary[@"position"];
|
|
173
|
+
|
|
174
|
+
// Populate the OnMapPressCoordinate struct
|
|
175
|
+
facebook::react::RNMapsMapViewEventEmitter::OnDoublePressCoordinate coordinate = {
|
|
176
|
+
.latitude = [coordinateDict[@"latitude"] doubleValue],
|
|
177
|
+
.longitude = [coordinateDict[@"longitude"] doubleValue],
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
// Populate the OnMapDouplePressPosition struct
|
|
181
|
+
facebook::react::RNMapsMapViewEventEmitter::OnDoublePressPosition position = {
|
|
182
|
+
.x = [positionDict[@"x"] doubleValue],
|
|
183
|
+
.y = [positionDict[@"y"] doubleValue],
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
|
|
188
|
+
facebook::react::RNMapsMapViewEventEmitter::OnDoublePress data = {
|
|
189
|
+
.position = position,
|
|
190
|
+
.coordinate = coordinate
|
|
191
|
+
};
|
|
192
|
+
mapViewEventEmitter->onDoublePress(data);
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
_view.onPanDrag = [self](NSDictionary* dictionary) {
|
|
197
|
+
if (_eventEmitter) {
|
|
198
|
+
|
|
199
|
+
NSDictionary* coordinateDict = dictionary[@"coordinate"];
|
|
200
|
+
NSDictionary* positionDict = dictionary[@"position"];
|
|
201
|
+
|
|
202
|
+
// Populate the OnMapPressCoordinate struct
|
|
203
|
+
facebook::react::RNMapsMapViewEventEmitter::OnPanDragCoordinate coordinate = {
|
|
204
|
+
.latitude = [coordinateDict[@"latitude"] doubleValue],
|
|
205
|
+
.longitude = [coordinateDict[@"longitude"] doubleValue],
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
// Populate the OnMapDouplePressPosition struct
|
|
209
|
+
facebook::react::RNMapsMapViewEventEmitter::OnPanDragPosition position = {
|
|
210
|
+
.x = [positionDict[@"x"] doubleValue],
|
|
211
|
+
.y = [positionDict[@"y"] doubleValue],
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
|
|
215
|
+
facebook::react::RNMapsMapViewEventEmitter::OnPanDrag data = {
|
|
216
|
+
.position = position,
|
|
217
|
+
.coordinate = coordinate,
|
|
218
|
+
};
|
|
219
|
+
mapViewEventEmitter->onPanDrag(data);
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
_view.onUserLocationChange = [self](NSDictionary* dictionary) {
|
|
224
|
+
if (_eventEmitter) {
|
|
225
|
+
|
|
226
|
+
NSDictionary* coordinateDict = dictionary[@"coordinate"];
|
|
227
|
+
NSDictionary* errorDict = dictionary[@"error"];
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
// Populate the OnMapPressCoordinate struct
|
|
231
|
+
facebook::react::RNMapsMapViewEventEmitter::OnUserLocationChangeCoordinate coordinate = {
|
|
232
|
+
.latitude = [coordinateDict[@"latitude"] doubleValue],
|
|
233
|
+
.longitude = [coordinateDict[@"longitude"] doubleValue],
|
|
234
|
+
};
|
|
235
|
+
NSString* str = @"";
|
|
236
|
+
if (errorDict){
|
|
237
|
+
str = errorDict[@"message"];
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
facebook::react::RNMapsMapViewEventEmitter::OnUserLocationChangeError error = {
|
|
241
|
+
.message = std::string([str UTF8String]),
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
|
|
246
|
+
facebook::react::RNMapsMapViewEventEmitter::OnUserLocationChange data = {
|
|
247
|
+
.coordinate = coordinate,
|
|
248
|
+
.error = error,
|
|
249
|
+
};
|
|
250
|
+
mapViewEventEmitter->onUserLocationChange(data);
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
_view.onCalloutPress = [self](NSDictionary* dictionary) {
|
|
255
|
+
if (_eventEmitter) {
|
|
256
|
+
|
|
257
|
+
NSDictionary* coordinateDict = dictionary[@"coordinate"];
|
|
258
|
+
NSDictionary* positionDict = dictionary[@"position"];
|
|
259
|
+
|
|
260
|
+
// Populate the OnCalloutPressPoint struct
|
|
261
|
+
facebook::react::RNMapsMapViewEventEmitter::OnCalloutPressPoint point = {
|
|
262
|
+
.x = [coordinateDict[@"x"] doubleValue],
|
|
263
|
+
.y = [coordinateDict[@"y"] doubleValue],
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
facebook::react::RNMapsMapViewEventEmitter::OnCalloutPressFrame frame = {
|
|
268
|
+
.x = [positionDict[@"x"] doubleValue],
|
|
269
|
+
.y = [positionDict[@"y"] doubleValue],
|
|
270
|
+
.width = [positionDict[@"width"] doubleValue],
|
|
271
|
+
.height = [positionDict[@"height"] doubleValue],
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
|
|
275
|
+
facebook::react::RNMapsMapViewEventEmitter::OnCalloutPress data = {
|
|
276
|
+
.action = std::string([dictionary[@"action"] UTF8String]),
|
|
277
|
+
.id = std::string([dictionary[@"id"] UTF8String]),
|
|
278
|
+
.point = point,
|
|
279
|
+
.frame = frame,
|
|
280
|
+
};
|
|
281
|
+
mapViewEventEmitter->onCalloutPress(data);
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
_view.onRegionChangeStart = [self](NSDictionary* dictionary) {
|
|
287
|
+
if (_eventEmitter) {
|
|
288
|
+
|
|
289
|
+
NSDictionary* regionDict = dictionary[@"region"];
|
|
290
|
+
auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
|
|
291
|
+
facebook::react::RNMapsMapViewEventEmitter::OnRegionChangeStart data = {
|
|
292
|
+
.region.latitude = [regionDict[@"latitude"] doubleValue],
|
|
293
|
+
.region.longitude = [regionDict[@"longitude"] doubleValue],
|
|
294
|
+
.region.latitudeDelta = [regionDict[@"latitudeDelta"] doubleValue],
|
|
295
|
+
.region.longitudeDelta = [regionDict[@"longitudeDelta"] doubleValue],
|
|
296
|
+
.continuous = [dictionary[@"continuous"] boolValue],
|
|
297
|
+
};
|
|
298
|
+
mapViewEventEmitter->onRegionChangeStart(data);
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
|
|
298
303
|
#define HANDLE_MARKER_DRAG_EVENT(eventName, emitterFunction) \
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
304
|
+
if (_eventEmitter) { \
|
|
305
|
+
NSDictionary* coordinateDict = dictionary[@"coordinate"]; \
|
|
306
|
+
auto mapViewEventEmitter = \
|
|
307
|
+
std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter); \
|
|
308
|
+
facebook::react::RNMapsMapViewEventEmitter::eventName data = { \
|
|
309
|
+
.coordinate.latitude = [coordinateDict[@"latitude"] doubleValue], \
|
|
310
|
+
.coordinate.longitude = [coordinateDict[@"longitude"] doubleValue], \
|
|
311
|
+
.id = std::string([[dictionary valueForKey:@"id"] UTF8String]), \
|
|
312
|
+
}; \
|
|
313
|
+
mapViewEventEmitter->emitterFunction(data); \
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
|
|
313
318
|
#define HANDLE_MARKER_EVENT(eventName, emitterFunction, actionName) \
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
319
|
+
if (_eventEmitter) { \
|
|
320
|
+
NSDictionary* coordinateDict = dictionary[@"coordinate"]; \
|
|
321
|
+
facebook::react::RNMapsMapViewEventEmitter::eventName##Coordinate coordinate = { \
|
|
322
|
+
.latitude = [coordinateDict[@"latitude"] doubleValue], \
|
|
323
|
+
.longitude = [coordinateDict[@"longitude"] doubleValue], \
|
|
324
|
+
}; \
|
|
325
|
+
\
|
|
326
|
+
auto mapViewEventEmitter = \
|
|
327
|
+
std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter); \
|
|
328
|
+
facebook::react::RNMapsMapViewEventEmitter::eventName data = { \
|
|
329
|
+
.action = std::string([@actionName UTF8String]), \
|
|
330
|
+
.id = std::string([[dictionary valueForKey:@"id"] UTF8String]), \
|
|
331
|
+
.coordinate = coordinate \
|
|
332
|
+
}; \
|
|
333
|
+
mapViewEventEmitter->emitterFunction(data); \
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
_view.onMarkerDrag = [self](NSDictionary* dictionary) {
|
|
337
|
+
HANDLE_MARKER_DRAG_EVENT(OnMarkerDrag, onMarkerDrag);
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
_view.onMarkerDragStart = [self](NSDictionary* dictionary) {
|
|
341
|
+
HANDLE_MARKER_DRAG_EVENT(OnMarkerDragStart, onMarkerDragStart);
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
_view.onMarkerDragEnd = [self](NSDictionary* dictionary) {
|
|
345
|
+
HANDLE_MARKER_DRAG_EVENT(OnMarkerDragEnd, onMarkerDragEnd);
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
_view.onMarkerSelect = [self](NSDictionary* dictionary) {
|
|
349
|
+
HANDLE_MARKER_EVENT(OnMarkerSelect, onMarkerSelect, "marker-select");
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
_view.onMarkerDeselect = [self](NSDictionary* dictionary) {
|
|
353
|
+
HANDLE_MARKER_EVENT(OnMarkerDeselect, onMarkerDeselect, "marker-deselect");
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
_view.onMarkerPress = [self](NSDictionary* dictionary) {
|
|
357
|
+
HANDLE_MARKER_EVENT(OnMarkerPress, onMarkerPress, "marker-press");
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
- (instancetype)initWithFrame:(CGRect)frame
|
|
361
|
+
{
|
|
362
|
+
if (self = [super initWithFrame:frame]) {
|
|
363
|
+
[self prepareMapView];
|
|
329
364
|
}
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
HANDLE_MARKER_DRAG_EVENT(OnMarkerDrag, onMarkerDrag);
|
|
333
|
-
};
|
|
334
|
-
|
|
335
|
-
_view.onMarkerDragStart = [self](NSDictionary* dictionary) {
|
|
336
|
-
HANDLE_MARKER_DRAG_EVENT(OnMarkerDragStart, onMarkerDragStart);
|
|
337
|
-
};
|
|
338
|
-
|
|
339
|
-
_view.onMarkerDragEnd = [self](NSDictionary* dictionary) {
|
|
340
|
-
HANDLE_MARKER_DRAG_EVENT(OnMarkerDragEnd, onMarkerDragEnd);
|
|
341
|
-
};
|
|
342
|
-
|
|
343
|
-
_view.onMarkerSelect = [self](NSDictionary* dictionary) {
|
|
344
|
-
HANDLE_MARKER_EVENT(OnMarkerSelect, onMarkerSelect, "marker-select");
|
|
345
|
-
};
|
|
346
|
-
|
|
347
|
-
_view.onMarkerDeselect = [self](NSDictionary* dictionary) {
|
|
348
|
-
HANDLE_MARKER_EVENT(OnMarkerDeselect, onMarkerDeselect, "marker-deselect");
|
|
349
|
-
};
|
|
350
|
-
|
|
351
|
-
_view.onMarkerPress = [self](NSDictionary* dictionary) {
|
|
352
|
-
HANDLE_MARKER_EVENT(OnMarkerPress, onMarkerPress, "marker-press");
|
|
353
|
-
};
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
return self;
|
|
365
|
+
|
|
366
|
+
return self;
|
|
360
367
|
}
|
|
361
368
|
|
|
362
369
|
|
|
@@ -393,106 +400,112 @@ MKMapType mapRNTypeToMKMapType(RNMapsMapViewMapType rnMapType) {
|
|
|
393
400
|
|
|
394
401
|
- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
|
|
395
402
|
{
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
403
|
+
[self prepareMapView];
|
|
404
|
+
const auto &oldViewProps = *std::static_pointer_cast<RNMapsMapViewProps const>(_props);
|
|
405
|
+
const auto &newViewProps = *std::static_pointer_cast<RNMapsMapViewProps const>(props);
|
|
406
|
+
|
|
399
407
|
#define REMAP_MAPVIEW_PROP(name) \
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
408
|
+
if (oldViewProps.name != newViewProps.name) { \
|
|
409
|
+
_view.name = newViewProps.name; \
|
|
410
|
+
}
|
|
411
|
+
|
|
404
412
|
#define REMAP_MAPVIEW_STRING_PROP(name) \
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
413
|
+
if (oldViewProps.name != newViewProps.name) { \
|
|
414
|
+
_view.name = RCTNSStringFromString(newViewProps.name); \
|
|
415
|
+
}
|
|
416
|
+
|
|
409
417
|
#define REMAP_MAPVIEW_COLOR_PROP(name) \
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
418
|
+
if (oldViewProps.name != newViewProps.name) { \
|
|
419
|
+
_view.name = RCTUIColorFromSharedColor(newViewProps.name); \
|
|
420
|
+
}
|
|
421
|
+
|
|
414
422
|
#define REMAP_MAPVIEW_POINT_PROP(name) \
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
423
|
+
if (newViewProps.name.x != oldViewProps.name.x || \
|
|
424
|
+
newViewProps.name.y != oldViewProps.name.y) { \
|
|
425
|
+
_view.name = CGPointMake(newViewProps.name.x, newViewProps.name.y); \
|
|
426
|
+
}
|
|
427
|
+
|
|
420
428
|
#define REMAP_MAPVIEW_REGION_PROP(name) \
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
429
|
+
if (newViewProps.name.latitude != oldViewProps.name.latitude || \
|
|
430
|
+
newViewProps.name.longitude != oldViewProps.name.longitude || \
|
|
431
|
+
newViewProps.name.latitudeDelta != oldViewProps.name.latitudeDelta ||\
|
|
432
|
+
newViewProps.name.longitudeDelta != oldViewProps.name.longitudeDelta) { \
|
|
433
|
+
MKCoordinateSpan span = MKCoordinateSpanMake(newViewProps.name.latitudeDelta, \
|
|
434
|
+
newViewProps.name.longitudeDelta); \
|
|
435
|
+
MKCoordinateRegion region = MKCoordinateRegionMake(CLLocationCoordinate2DMake( \
|
|
436
|
+
newViewProps.name.latitude, newViewProps.name.longitude), span); \
|
|
437
|
+
_view.name = region; \
|
|
438
|
+
[_view didSetRegion]; \
|
|
439
|
+
}
|
|
440
|
+
|
|
432
441
|
#define REMAP_MAPVIEW_CAMERA_PROP(name) \
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
442
|
+
if (newViewProps.name.center.latitude != oldViewProps.name.center.latitude || \
|
|
443
|
+
newViewProps.name.center.longitude != oldViewProps.name.center.longitude || \
|
|
444
|
+
newViewProps.name.heading != oldViewProps.name.heading || \
|
|
445
|
+
newViewProps.name.pitch != oldViewProps.name.pitch) { \
|
|
446
|
+
CLLocationCoordinate2D center = CLLocationCoordinate2DMake( \
|
|
447
|
+
newViewProps.name.center.latitude, \
|
|
448
|
+
newViewProps.name.center.longitude); \
|
|
449
|
+
MKMapCamera* camera = [[MKMapCamera alloc] init]; \
|
|
450
|
+
camera.centerCoordinate = center; \
|
|
451
|
+
camera.heading = newViewProps.name.heading; \
|
|
452
|
+
camera.pitch = newViewProps.name.pitch; \
|
|
453
|
+
_view.name = camera; \
|
|
454
|
+
}
|
|
455
|
+
|
|
447
456
|
#define REMAP_MAPVIEW_EDGEINSETS_PROP(name) \
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
457
|
+
if (newViewProps.name.top != oldViewProps.name.top || \
|
|
458
|
+
newViewProps.name.right != oldViewProps.name.right || \
|
|
459
|
+
newViewProps.name.bottom != oldViewProps.name.bottom || \
|
|
460
|
+
newViewProps.name.left != oldViewProps.name.left) { \
|
|
461
|
+
_view.name = UIEdgeInsetsMake(newViewProps.name.top, \
|
|
462
|
+
newViewProps.name.left, \
|
|
463
|
+
newViewProps.name.bottom, \
|
|
464
|
+
newViewProps.name.right); \
|
|
465
|
+
}
|
|
466
|
+
|
|
458
467
|
#define REMAP_MAPVIEW_MAPTYPE(rnMapType) MKMapType##rnMapType
|
|
459
|
-
|
|
460
|
-
|
|
468
|
+
|
|
469
|
+
|
|
461
470
|
REMAP_MAPVIEW_PROP(cacheEnabled)
|
|
462
|
-
|
|
471
|
+
|
|
463
472
|
REMAP_MAPVIEW_PROP(followsUserLocation)
|
|
464
473
|
REMAP_MAPVIEW_PROP(loadingEnabled)
|
|
465
474
|
REMAP_MAPVIEW_PROP(scrollEnabled)
|
|
466
|
-
|
|
475
|
+
|
|
467
476
|
REMAP_MAPVIEW_PROP(maxDelta)
|
|
468
477
|
REMAP_MAPVIEW_PROP(maxZoom)
|
|
469
478
|
REMAP_MAPVIEW_PROP(minDelta)
|
|
470
479
|
REMAP_MAPVIEW_PROP(minZoom)
|
|
471
|
-
|
|
480
|
+
|
|
472
481
|
REMAP_MAPVIEW_PROP(showsCompass)
|
|
473
482
|
REMAP_MAPVIEW_PROP(showsScale)
|
|
474
483
|
REMAP_MAPVIEW_PROP(showsTraffic)
|
|
475
484
|
REMAP_MAPVIEW_PROP(showsUserLocation)
|
|
476
485
|
REMAP_MAPVIEW_PROP(userLocationCalloutEnabled)
|
|
477
486
|
REMAP_MAPVIEW_PROP(zoomEnabled)
|
|
478
|
-
|
|
487
|
+
|
|
479
488
|
REMAP_MAPVIEW_POINT_PROP(compassOffset)
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
489
|
+
|
|
490
|
+
if (![_view ignoreRegionChanges]){
|
|
491
|
+
_view.ignoreRegionChanges = YES;
|
|
492
|
+
REMAP_MAPVIEW_REGION_PROP(initialRegion)
|
|
493
|
+
REMAP_MAPVIEW_REGION_PROP(region)
|
|
494
|
+
_view.ignoreRegionChanges = NO;
|
|
495
|
+
}
|
|
496
|
+
|
|
484
497
|
REMAP_MAPVIEW_CAMERA_PROP(initialCamera)
|
|
485
498
|
REMAP_MAPVIEW_CAMERA_PROP(camera)
|
|
486
|
-
|
|
499
|
+
|
|
487
500
|
REMAP_MAPVIEW_EDGEINSETS_PROP(legalLabelInsets)
|
|
488
501
|
REMAP_MAPVIEW_EDGEINSETS_PROP(mapPadding)
|
|
489
|
-
|
|
502
|
+
|
|
490
503
|
REMAP_MAPVIEW_COLOR_PROP(loadingIndicatorColor)
|
|
491
504
|
REMAP_MAPVIEW_COLOR_PROP(loadingIndicatorColor)
|
|
492
505
|
REMAP_MAPVIEW_COLOR_PROP(tintColor)
|
|
493
|
-
|
|
506
|
+
|
|
494
507
|
REMAP_MAPVIEW_STRING_PROP(userLocationAnnotationTitle)
|
|
495
|
-
|
|
508
|
+
|
|
496
509
|
if (oldViewProps.mapType != newViewProps.mapType){
|
|
497
510
|
_view.mapType = mapRNTypeToMKMapType(newViewProps.mapType);
|
|
498
511
|
}
|
|
@@ -509,22 +522,22 @@ MKMapType mapRNTypeToMKMapType(RNMapsMapViewMapType rnMapType) {
|
|
|
509
522
|
break;
|
|
510
523
|
}
|
|
511
524
|
}
|
|
512
|
-
|
|
525
|
+
|
|
513
526
|
if (oldViewProps.cameraZoomRange.minCenterCoordinateDistance != newViewProps.cameraZoomRange.minCenterCoordinateDistance ||
|
|
514
527
|
oldViewProps.cameraZoomRange.maxCenterCoordinateDistance != newViewProps.cameraZoomRange.maxCenterCoordinateDistance ||
|
|
515
528
|
oldViewProps.cameraZoomRange.animated != newViewProps.cameraZoomRange.animated) {
|
|
516
|
-
|
|
529
|
+
|
|
517
530
|
MKMapCameraZoomRange* zoomRange = [[MKMapCameraZoomRange alloc] initWithMinCenterCoordinateDistance:newViewProps.cameraZoomRange.minCenterCoordinateDistance maxCenterCoordinateDistance:newViewProps.cameraZoomRange.maxCenterCoordinateDistance];
|
|
518
531
|
[_view setCameraZoomRange:zoomRange animated:newViewProps.cameraZoomRange.animated];
|
|
519
532
|
}
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
533
|
+
|
|
534
|
+
|
|
535
|
+
[super updateProps:props oldProps:oldProps];
|
|
523
536
|
}
|
|
524
537
|
|
|
525
538
|
@end
|
|
526
539
|
|
|
527
540
|
Class<RCTComponentViewProtocol> RNMapsMapViewCls(void)
|
|
528
541
|
{
|
|
529
|
-
|
|
542
|
+
return RNMapsMapView.class;
|
|
530
543
|
}
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"author": "Leland Richardson <leland.m.richardson@gmail.com>",
|
|
7
7
|
"homepage": "https://github.com/react-native-maps/react-native-maps#readme",
|
|
8
|
-
"version": "1.21.0-alpha.
|
|
8
|
+
"version": "1.21.0-alpha.13",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"lint": "eslint . --max-warnings 0",
|