react-native-maps 1.21.0-alpha.14 → 1.21.0-alpha.16
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 +8 -1
- package/ios/AirGoogleMaps/AIRGoogleMapWMSTile.h +1 -1
- package/ios/AirGoogleMaps/AIRGoogleMapWMSTile.m +2 -2
- package/ios/AirGoogleMaps/RNMapsGoogleMapView.mm +34 -18
- 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 +1 -0
- package/ios/AirMaps/AIRMap.m +3 -2
- package/ios/AirMaps/RNMapsMapView.mm +81 -74
- package/lib/MapView.js +7 -7
- package/lib/decorateMapComponent.js +11 -0
- package/lib/specs/NativeComponentGooglePolygon.d.ts +75 -0
- package/lib/specs/NativeComponentGooglePolygon.js +9 -0
- package/lib/specs/NativeComponentMapView.d.ts +1 -0
- package/package.json +1 -1
|
@@ -246,6 +246,11 @@ id regionAsJSON(MKCoordinateRegion region) {
|
|
|
246
246
|
AIRGoogleMapPolygon *polygon = (AIRGoogleMapPolygon*)subview;
|
|
247
247
|
[polygon didInsertInMap:self];
|
|
248
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];
|
|
249
254
|
} else if ([subview isKindOfClass:[AIRGoogleMapPolyline class]]) {
|
|
250
255
|
AIRGoogleMapPolyline *polyline = (AIRGoogleMapPolyline*)subview;
|
|
251
256
|
polyline.polyline.map = self;
|
|
@@ -290,7 +295,9 @@ id regionAsJSON(MKCoordinateRegion region) {
|
|
|
290
295
|
AIRGoogleMapMarker *marker = (AIRGoogleMapMarker*)subview;
|
|
291
296
|
marker.realMarker.map = nil;
|
|
292
297
|
[self.markers removeObject:marker];
|
|
293
|
-
} else if ([subview
|
|
298
|
+
} else if ([NSStringFromClass([subview class]) isEqualToString:@"RNMapsGooglePolygonView"]) {
|
|
299
|
+
[self.polygons removeObject:subview];
|
|
300
|
+
} else if ([subview isKindOfClass:[AIRGoogleMapPolygon class]]) {
|
|
294
301
|
AIRGoogleMapPolygon *polygon = (AIRGoogleMapPolygon*)subview;
|
|
295
302
|
polygon.polygon.map = nil;
|
|
296
303
|
[self.polygons removeObject:polygon];
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
@interface WMSTileOverlay : GMSSyncTileLayer
|
|
15
15
|
@property (nonatomic) double MapX,MapY,FULL;
|
|
16
|
-
@property (nonatomic,
|
|
16
|
+
@property (nonatomic, assign) NSString *urlTemplate;
|
|
17
17
|
@property (nonatomic, assign) NSInteger maximumZ;
|
|
18
18
|
@property (nonatomic, assign) NSInteger minimumZ;
|
|
19
19
|
@end
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
{
|
|
63
63
|
_urlTemplate = urlTemplate;
|
|
64
64
|
WMSTileOverlay *tile = [[WMSTileOverlay alloc] init];
|
|
65
|
-
[tile
|
|
65
|
+
[tile setUrlTemplate:urlTemplate];
|
|
66
66
|
[tile setMaximumZ: _maximumZ];
|
|
67
67
|
[tile setMinimumZ: _minimumZ];
|
|
68
68
|
[tile setOpacity: _opacity];
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
return nil;
|
|
108
108
|
}
|
|
109
109
|
NSArray *bb = [self getBoundBox:x yAxis:y zoom:zoom];
|
|
110
|
-
NSMutableString *url = [self.
|
|
110
|
+
NSMutableString *url = [self.urlTemplate mutableCopy];
|
|
111
111
|
[url replaceOccurrencesOfString: @"{minX}" withString:[NSString stringWithFormat:@"%@", bb[0]] options:0 range:NSMakeRange(0, url.length)];
|
|
112
112
|
[url replaceOccurrencesOfString: @"{minY}" withString:[NSString stringWithFormat:@"%@", bb[1]] options:0 range:NSMakeRange(0, url.length)];
|
|
113
113
|
[url replaceOccurrencesOfString: @"{maxX}" withString:[NSString stringWithFormat:@"%@", bb[2]] options:0 range:NSMakeRange(0, url.length)];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//
|
|
2
2
|
// RNMapsGoogleMapView.mm
|
|
3
|
-
//
|
|
3
|
+
//
|
|
4
4
|
//
|
|
5
5
|
// Created by Salah Ghanim on 23.11.24.
|
|
6
6
|
// Copyright © 2024 react-native-maps. All rights reserved.
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
#ifdef HAVE_GOOGLE_MAPS
|
|
9
9
|
|
|
10
10
|
#import "RNMapsGoogleMapView.h"
|
|
11
|
+
#import "RNMapsGooglePolygonView.h"
|
|
11
12
|
#import "AirGoogleMap.h"
|
|
12
13
|
#import "AIRMapMarker.h"
|
|
13
14
|
#import "AirGoogleMapManager.h"
|
|
@@ -32,6 +33,7 @@ using namespace facebook::react;
|
|
|
32
33
|
AIRGoogleMap *_view;
|
|
33
34
|
AIRGoogleMapManager* _legacyMapManager;
|
|
34
35
|
NSMutableDictionary<NSNumber*, UIView*>* _pendingInsertsSubviews;
|
|
36
|
+
NSMutableArray *_polygons;
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
|
|
@@ -77,7 +79,7 @@ using namespace facebook::react;
|
|
|
77
79
|
}
|
|
78
80
|
|
|
79
81
|
NSDictionary* edgePadding = [RCTConvert dictonaryFromString:edgePaddingJSON];
|
|
80
|
-
|
|
82
|
+
|
|
81
83
|
[_view fitToCoordinates:coordinatesArray withEdgePadding:edgePadding animated:animated];
|
|
82
84
|
}
|
|
83
85
|
|
|
@@ -108,9 +110,10 @@ using namespace facebook::react;
|
|
|
108
110
|
}
|
|
109
111
|
|
|
110
112
|
- (void) prepareContentView {
|
|
111
|
-
|
|
113
|
+
|
|
112
114
|
_view = (AIRGoogleMap *)[_legacyMapManager view];
|
|
113
|
-
|
|
115
|
+
_polygons = [NSMutableArray new];
|
|
116
|
+
|
|
114
117
|
self.contentView = _view;
|
|
115
118
|
|
|
116
119
|
_view.onPress = [self](NSDictionary* dictionary) {
|
|
@@ -140,7 +143,7 @@ using namespace facebook::react;
|
|
|
140
143
|
mapViewEventEmitter->onPress(data);
|
|
141
144
|
}
|
|
142
145
|
};
|
|
143
|
-
|
|
146
|
+
|
|
144
147
|
_view.onLongPress = [self](NSDictionary* dictionary) {
|
|
145
148
|
if (_eventEmitter) {
|
|
146
149
|
// Extract values from the NSDictionary
|
|
@@ -177,7 +180,7 @@ using namespace facebook::react;
|
|
|
177
180
|
mapViewEventEmitter->onMapReady(data);
|
|
178
181
|
}
|
|
179
182
|
};
|
|
180
|
-
|
|
183
|
+
|
|
181
184
|
_view.onMapLoaded = [self](NSDictionary* dictionary) {
|
|
182
185
|
if (_eventEmitter) {
|
|
183
186
|
auto mapViewEventEmitter = std::static_pointer_cast<RNMapsGoogleMapViewEventEmitter const>(_eventEmitter);
|
|
@@ -185,7 +188,7 @@ using namespace facebook::react;
|
|
|
185
188
|
mapViewEventEmitter->onMapLoaded(data);
|
|
186
189
|
}
|
|
187
190
|
};
|
|
188
|
-
|
|
191
|
+
|
|
189
192
|
_view.onKmlReady = [self](NSDictionary* dictionary) {
|
|
190
193
|
if (_eventEmitter) {
|
|
191
194
|
|
|
@@ -253,7 +256,7 @@ using namespace facebook::react;
|
|
|
253
256
|
if (errorDict){
|
|
254
257
|
str = errorDict[@"message"];
|
|
255
258
|
}
|
|
256
|
-
|
|
259
|
+
|
|
257
260
|
facebook::react::RNMapsGoogleMapViewEventEmitter::OnUserLocationChangeError error = {
|
|
258
261
|
.message = std::string([str UTF8String]),
|
|
259
262
|
};
|
|
@@ -285,7 +288,7 @@ using namespace facebook::react;
|
|
|
285
288
|
mapViewEventEmitter->onRegionChangeStart(data);
|
|
286
289
|
}
|
|
287
290
|
};
|
|
288
|
-
|
|
291
|
+
|
|
289
292
|
_view.onRegionChange = [self](NSDictionary* dictionary) {
|
|
290
293
|
if (_eventEmitter) {
|
|
291
294
|
|
|
@@ -301,7 +304,7 @@ using namespace facebook::react;
|
|
|
301
304
|
mapViewEventEmitter->onRegionChange(data);
|
|
302
305
|
}
|
|
303
306
|
};
|
|
304
|
-
|
|
307
|
+
|
|
305
308
|
_view.onRegionChangeComplete = [self](NSDictionary* dictionary) {
|
|
306
309
|
if (_eventEmitter) {
|
|
307
310
|
|
|
@@ -388,6 +391,11 @@ using namespace facebook::react;
|
|
|
388
391
|
}
|
|
389
392
|
} else {
|
|
390
393
|
[_view insertReactSubview:childComponentView atIndex:index];
|
|
394
|
+
if ([childComponentView isKindOfClass:[RNMapsGooglePolygonView class]]){
|
|
395
|
+
RNMapsGooglePolygonView* polygon = (RNMapsGooglePolygonView *) childComponentView;
|
|
396
|
+
[_polygons addObject:childComponentView];
|
|
397
|
+
[polygon didInsertInMap:_view];
|
|
398
|
+
}
|
|
391
399
|
}
|
|
392
400
|
}
|
|
393
401
|
|
|
@@ -402,6 +410,11 @@ using namespace facebook::react;
|
|
|
402
410
|
}
|
|
403
411
|
} else {
|
|
404
412
|
[_view removeReactSubview:childComponentView];
|
|
413
|
+
if ([childComponentView isKindOfClass:[RNMapsGooglePolygonView class]]){
|
|
414
|
+
RNMapsGooglePolygonView* polygon = (RNMapsGooglePolygonView *) childComponentView;
|
|
415
|
+
[_polygons removeObject:childComponentView];
|
|
416
|
+
[polygon didRemoveFromMap];
|
|
417
|
+
}
|
|
405
418
|
}
|
|
406
419
|
}
|
|
407
420
|
- (void) prepareForRecycle
|
|
@@ -420,7 +433,7 @@ using namespace facebook::react;
|
|
|
420
433
|
{
|
|
421
434
|
const auto &oldViewProps = *std::static_pointer_cast<RNMapsGoogleMapViewProps const>(_props);
|
|
422
435
|
const auto &newViewProps = *std::static_pointer_cast<RNMapsGoogleMapViewProps const>(props);
|
|
423
|
-
|
|
436
|
+
|
|
424
437
|
|
|
425
438
|
if (oldViewProps.googleMapId != newViewProps.googleMapId) {
|
|
426
439
|
NSString* mapID = RCTNSStringFromString(newViewProps.googleMapId);
|
|
@@ -452,7 +465,7 @@ using namespace facebook::react;
|
|
|
452
465
|
_legacyMapManager.camera = camera;
|
|
453
466
|
}
|
|
454
467
|
|
|
455
|
-
|
|
468
|
+
|
|
456
469
|
|
|
457
470
|
if (!_view){
|
|
458
471
|
[self prepareContentView];
|
|
@@ -500,11 +513,14 @@ using namespace facebook::react;
|
|
|
500
513
|
|
|
501
514
|
|
|
502
515
|
REMAP_MAPVIEW_PROP(pitchEnabled)
|
|
503
|
-
|
|
516
|
+
|
|
504
517
|
REMAP_MAPVIEW_PROP(zoomTapEnabled)
|
|
505
|
-
|
|
518
|
+
|
|
506
519
|
REMAP_MAPVIEW_PROP(scrollEnabled)
|
|
507
|
-
|
|
520
|
+
if (_view.scrollEnabled != newViewProps.scrollEnabled){
|
|
521
|
+
[_view setScrollEnabled:newViewProps.scrollEnabled];
|
|
522
|
+
}
|
|
523
|
+
|
|
508
524
|
if (newViewProps.minZoom != oldViewProps.minZoom || newViewProps.maxZoom != oldViewProps.maxZoom){
|
|
509
525
|
[_view setMinZoom:newViewProps.minZoom maxZoom:newViewProps.maxZoom];
|
|
510
526
|
}
|
|
@@ -530,8 +546,8 @@ using namespace facebook::react;
|
|
|
530
546
|
viewingAngle:newViewProps.camera.pitch];
|
|
531
547
|
_view.cameraProp = camera;
|
|
532
548
|
}
|
|
533
|
-
|
|
534
|
-
|
|
549
|
+
|
|
550
|
+
|
|
535
551
|
REMAP_MAPVIEW_EDGEINSETS_PROP(mapPadding)
|
|
536
552
|
|
|
537
553
|
|
|
@@ -554,7 +570,7 @@ using namespace facebook::react;
|
|
|
554
570
|
break;
|
|
555
571
|
}
|
|
556
572
|
}
|
|
557
|
-
|
|
573
|
+
|
|
558
574
|
if (oldViewProps.userInterfaceStyle != newViewProps.userInterfaceStyle){
|
|
559
575
|
switch (newViewProps.userInterfaceStyle) {
|
|
560
576
|
case RNMapsGoogleMapViewUserInterfaceStyle::Light:
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//
|
|
2
|
+
// RNMapsGoogleMapView.h
|
|
3
|
+
//
|
|
4
|
+
//
|
|
5
|
+
// Created by Salah Ghanim on 23.11.24.
|
|
6
|
+
// Copyright © 2024 react-native-maps. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
9
|
+
#ifdef HAVE_GOOGLE_MAPS
|
|
10
|
+
|
|
11
|
+
#import <React/RCTViewComponentView.h>
|
|
12
|
+
#import <UIKit/UIKit.h>
|
|
13
|
+
|
|
14
|
+
@class AIRGoogleMap;
|
|
15
|
+
@class AIRGMSPolygon;
|
|
16
|
+
|
|
17
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
18
|
+
@interface RNMapsGooglePolygonView : RCTViewComponentView
|
|
19
|
+
- (void) didInsertInMap:(AIRGoogleMap*) map;
|
|
20
|
+
- (void) didRemoveFromMap;
|
|
21
|
+
@end
|
|
22
|
+
|
|
23
|
+
NS_ASSUME_NONNULL_END
|
|
24
|
+
|
|
25
|
+
#endif
|
|
26
|
+
#endif
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
//
|
|
2
|
+
// RNMapsGoogleMapView.mm
|
|
3
|
+
//
|
|
4
|
+
//
|
|
5
|
+
// Created by Salah Ghanim on 23.11.24.
|
|
6
|
+
// Copyright © 2024 react-native-maps. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
#ifdef HAVE_GOOGLE_MAPS
|
|
9
|
+
|
|
10
|
+
#import "RNMapsGooglePolygonView.h"
|
|
11
|
+
#import "AIRGMSPolygon.h"
|
|
12
|
+
#import "AIRGoogleMap.h"
|
|
13
|
+
|
|
14
|
+
#import <react/renderer/components/RNMapsSpecs/ComponentDescriptors.h>
|
|
15
|
+
#import <react/renderer/components/RNMapsSpecs/EventEmitters.h>
|
|
16
|
+
#import <react/renderer/components/RNMapsSpecs/Props.h>
|
|
17
|
+
#import <react/renderer/components/RNMapsSpecs/RCTComponentViewHelpers.h>
|
|
18
|
+
|
|
19
|
+
#import "RCTFabricComponentsPlugins.h"
|
|
20
|
+
#import <React/RCTConversions.h>
|
|
21
|
+
#import "RCTConvert+GMSMapViewType.h"
|
|
22
|
+
#import "RCTConvert+AirMap.h"
|
|
23
|
+
#import "UIView+AirMap.h"
|
|
24
|
+
|
|
25
|
+
using namespace facebook::react;
|
|
26
|
+
|
|
27
|
+
bool areHolesEqual(const std::vector<std::vector<RNMapsGooglePolygonHolesStruct>>& newHoles, const std::vector<std::vector<RNMapsGooglePolygonHolesStruct>>& oldHoles) {
|
|
28
|
+
// First-level check: compare the sizes of the top-level vectors
|
|
29
|
+
if (newHoles.size() != oldHoles.size()) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Second-level check: compare the contents of each child vector
|
|
34
|
+
for (size_t i = 0; i < newHoles.size(); ++i) {
|
|
35
|
+
const auto& newHole = newHoles.at(i);
|
|
36
|
+
const auto& oldHole = oldHoles.at(i);
|
|
37
|
+
|
|
38
|
+
// Compare sizes of the child vectors
|
|
39
|
+
if (newHole.size() != oldHole.size()) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@interface RNMapsGooglePolygonView () <RCTRNMapsGooglePolygonViewProtocol>
|
|
49
|
+
@end
|
|
50
|
+
|
|
51
|
+
@implementation RNMapsGooglePolygonView {
|
|
52
|
+
AIRGMSPolygon *_view;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
- (AIRGMSPolygon*) polygon {
|
|
57
|
+
return _view;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
61
|
+
{
|
|
62
|
+
return concreteComponentDescriptorProvider<RNMapsGooglePolygonComponentDescriptor>();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
- (void) didInsertInMap:(AIRGoogleMap*) map
|
|
66
|
+
{
|
|
67
|
+
_view.map = map;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
-(void) didRemoveFromMap
|
|
71
|
+
{
|
|
72
|
+
_view.map = nil;
|
|
73
|
+
_view = nil;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
- (void) prepareContentView {
|
|
77
|
+
|
|
78
|
+
_view = [AIRGMSPolygon new];
|
|
79
|
+
_view.onPress = [self](NSDictionary* dictionary) {
|
|
80
|
+
if (_eventEmitter) {
|
|
81
|
+
// Extract values from the NSDictionary
|
|
82
|
+
NSDictionary* coordinateDict = dictionary[@"coordinate"];
|
|
83
|
+
NSDictionary* positionDict = dictionary[@"position"];
|
|
84
|
+
|
|
85
|
+
// Populate the OnMapPressCoordinate struct
|
|
86
|
+
facebook::react::RNMapsGooglePolygonEventEmitter::OnPressCoordinate coordinate = {
|
|
87
|
+
.latitude = [coordinateDict[@"latitude"] doubleValue],
|
|
88
|
+
.longitude = [coordinateDict[@"longitude"] doubleValue],
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
// Populate the OnMapPressPosition struct
|
|
92
|
+
facebook::react::RNMapsGooglePolygonEventEmitter::OnPressPosition position = {
|
|
93
|
+
.x = [positionDict[@"x"] doubleValue],
|
|
94
|
+
.y = [positionDict[@"y"] doubleValue],
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
auto mapViewEventEmitter = std::static_pointer_cast<RNMapsGooglePolygonEventEmitter const>(_eventEmitter);
|
|
98
|
+
facebook::react::RNMapsGooglePolygonEventEmitter::OnPress data = {
|
|
99
|
+
.action = std::string([@"press" UTF8String]),
|
|
100
|
+
.position = position,
|
|
101
|
+
.coordinate = coordinate
|
|
102
|
+
};
|
|
103
|
+
mapViewEventEmitter->onPress(data);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
- (instancetype)initWithFrame:(CGRect)frame
|
|
110
|
+
{
|
|
111
|
+
if (self = [super initWithFrame:frame]) {
|
|
112
|
+
static const auto defaultProps = std::make_shared<const RNMapsGooglePolygonProps>();
|
|
113
|
+
_props = defaultProps;
|
|
114
|
+
[self prepareContentView];
|
|
115
|
+
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return self;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
- (void) prepareForRecycle
|
|
124
|
+
{
|
|
125
|
+
[super prepareForRecycle];
|
|
126
|
+
static const auto defaultProps = std::make_shared<const RNMapsGooglePolygonProps>();
|
|
127
|
+
_props = defaultProps;
|
|
128
|
+
_view = nil;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
|
|
133
|
+
{
|
|
134
|
+
const auto &oldViewProps = *std::static_pointer_cast<RNMapsGooglePolygonProps const>(_props);
|
|
135
|
+
const auto &newViewProps = *std::static_pointer_cast<RNMapsGooglePolygonProps const>(props);
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
if (!_view){
|
|
139
|
+
[self prepareContentView];
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
#define REMAP_MAPVIEW_PROP(name) \
|
|
143
|
+
if (oldViewProps.name != newViewProps.name) { \
|
|
144
|
+
_view.name = newViewProps.name; \
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
#define REMAP_MAPVIEW_STRING_PROP(name) \
|
|
148
|
+
if (oldViewProps.name != newViewProps.name) { \
|
|
149
|
+
_view.name = RCTNSStringFromString(newViewProps.name); \
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
#define REMAP_MAPVIEW_POINT_PROP(name) \
|
|
153
|
+
if (newViewProps.name.x != oldViewProps.name.x || \
|
|
154
|
+
newViewProps.name.y != oldViewProps.name.y) { \
|
|
155
|
+
_view.name = CGPointMake(newViewProps.name.x, newViewProps.name.y); \
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
if(newViewProps.zIndex.has_value()){
|
|
160
|
+
_view.zIndex = newViewProps.zIndex.value();
|
|
161
|
+
}
|
|
162
|
+
if (newViewProps.coordinates.size() != oldViewProps.coordinates.size()){
|
|
163
|
+
GMSMutablePath *path = [GMSMutablePath path];
|
|
164
|
+
for(int i = 0; i < newViewProps.coordinates.size(); i++)
|
|
165
|
+
{
|
|
166
|
+
CLLocationCoordinate2D coordinates = CLLocationCoordinate2DMake(
|
|
167
|
+
newViewProps.coordinates.at(i).latitude,newViewProps.coordinates.at(i).longitude);
|
|
168
|
+
[path addCoordinate:coordinates];
|
|
169
|
+
}
|
|
170
|
+
_view.path = path;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (!areHolesEqual(newViewProps.holes, oldViewProps.holes)){
|
|
174
|
+
NSMutableArray<GMSMutablePath *> *interiorPolygons = [NSMutableArray array];
|
|
175
|
+
for(int h = 0; h < newViewProps.holes.size(); h++)
|
|
176
|
+
{
|
|
177
|
+
GMSMutablePath *path = [GMSMutablePath path];
|
|
178
|
+
for(int i = 0; i < newViewProps.holes[h].size(); i++)
|
|
179
|
+
{
|
|
180
|
+
CLLocationCoordinate2D coordinates = CLLocationCoordinate2DMake(
|
|
181
|
+
newViewProps.holes.at(h).at(i).latitude,
|
|
182
|
+
newViewProps.holes.at(h).at(i).longitude);
|
|
183
|
+
[path addCoordinate:coordinates];
|
|
184
|
+
}
|
|
185
|
+
[interiorPolygons addObject:path];
|
|
186
|
+
}
|
|
187
|
+
_view.holes = interiorPolygons;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
REMAP_MAPVIEW_PROP(tappable)
|
|
192
|
+
|
|
193
|
+
if (newViewProps.fillColor){
|
|
194
|
+
_view.fillColor = RCTUIColorFromSharedColor(newViewProps.fillColor);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (newViewProps.strokeColor){
|
|
198
|
+
_view.strokeColor = RCTUIColorFromSharedColor(newViewProps.strokeColor);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
[super updateProps:props oldProps:oldProps];
|
|
205
|
+
}
|
|
206
|
+
- (void) didMoveToSuperview {
|
|
207
|
+
[super didMoveToSuperview];
|
|
208
|
+
NSLog(@"SuperView ? %@", self.superview);
|
|
209
|
+
}
|
|
210
|
+
@end
|
|
211
|
+
|
|
212
|
+
Class<RCTComponentViewProtocol> RNMapsGooglePolygonCls(void)
|
|
213
|
+
{
|
|
214
|
+
return RNMapsGooglePolygonView.class;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
#endif
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//
|
|
2
|
+
// RNMapsMapViewManager.mm
|
|
3
|
+
// AirMaps
|
|
4
|
+
//
|
|
5
|
+
// Created by Salah Ghanim on 23.11.24.
|
|
6
|
+
// Copyright © 2024 react-native-maps. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
#ifdef HAVE_GOOGLE_MAPS
|
|
9
|
+
|
|
10
|
+
#import <React/RCTLog.h>
|
|
11
|
+
#import <React/RCTUIManager.h>
|
|
12
|
+
#import <React/RCTViewManager.h>
|
|
13
|
+
|
|
14
|
+
@interface RNMapsGooglePolygonViewManager : RCTViewManager
|
|
15
|
+
@end
|
|
16
|
+
|
|
17
|
+
@implementation RNMapsGooglePolygonViewManager
|
|
18
|
+
|
|
19
|
+
RCT_EXPORT_MODULE(RNMapsGooglePolygonViewManager)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@end
|
|
24
|
+
|
|
25
|
+
#endif
|
package/ios/AirMaps/AIRMap.h
CHANGED
|
@@ -35,6 +35,7 @@ extern const NSInteger AIRMapMaxZoomLevel;
|
|
|
35
35
|
@property (nonatomic, assign) BOOL hasStartedRendering;
|
|
36
36
|
@property (nonatomic, assign) BOOL cacheEnabled;
|
|
37
37
|
@property (nonatomic, assign) BOOL loadingEnabled;
|
|
38
|
+
@property (nonatomic, assign) BOOL handlePanDrag;
|
|
38
39
|
@property (nonatomic, assign) BOOL legacyZoomConstraintsEnabled;
|
|
39
40
|
@property (nonatomic, strong) UIColor *loadingBackgroundColor;
|
|
40
41
|
@property (nonatomic, strong) UIColor *loadingIndicatorColor;
|
package/ios/AirMaps/AIRMap.m
CHANGED
|
@@ -538,13 +538,14 @@ MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coords count:coordina
|
|
|
538
538
|
_userLocationCalloutEnabled = calloutEnabled;
|
|
539
539
|
}
|
|
540
540
|
|
|
541
|
-
- (void)setHandlePanDrag:(BOOL)
|
|
541
|
+
- (void)setHandlePanDrag:(BOOL)handlePanDrag {
|
|
542
542
|
for (UIGestureRecognizer *recognizer in [self gestureRecognizers]) {
|
|
543
543
|
if ([recognizer isKindOfClass:[UIPanGestureRecognizer class]]) {
|
|
544
|
-
recognizer.enabled =
|
|
544
|
+
recognizer.enabled = handlePanDrag;
|
|
545
545
|
break;
|
|
546
546
|
}
|
|
547
547
|
}
|
|
548
|
+
_handlePanDrag = handlePanDrag;
|
|
548
549
|
}
|
|
549
550
|
|
|
550
551
|
- (void)setRegion:(MKCoordinateRegion)region animated:(BOOL)animated
|
|
@@ -82,12 +82,12 @@ using namespace facebook::react;
|
|
|
82
82
|
for (id json : coordinatesArr){
|
|
83
83
|
[mutableArray addObject:[RCTConvert AIRMapCoordinate:json]];
|
|
84
84
|
}
|
|
85
|
-
|
|
85
|
+
|
|
86
86
|
NSDictionary* edgePadding = [RCTConvert dictonaryFromString:edgePaddingJSON];
|
|
87
|
-
|
|
87
|
+
|
|
88
88
|
UIEdgeInsets edgeInsets = [RCTConvert UIEdgeInsets:edgePadding];
|
|
89
89
|
[_view fitToCoordinates:mutableArray edgePadding:edgeInsets animated:animated];
|
|
90
|
-
|
|
90
|
+
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
#pragma mark - Native commands
|
|
@@ -110,27 +110,27 @@ using namespace facebook::react;
|
|
|
110
110
|
_props = defaultProps;
|
|
111
111
|
_legacyMapManager = [[AIRMapManager alloc] init];
|
|
112
112
|
_view = (AIRMap *)[_legacyMapManager view];
|
|
113
|
-
|
|
113
|
+
|
|
114
114
|
self.contentView = _view;
|
|
115
|
-
|
|
115
|
+
|
|
116
116
|
_view.onPress = [self](NSDictionary* dictionary) {
|
|
117
117
|
if (_eventEmitter) {
|
|
118
118
|
// Extract values from the NSDictionary
|
|
119
119
|
NSDictionary* coordinateDict = dictionary[@"coordinate"];
|
|
120
120
|
NSDictionary* positionDict = dictionary[@"position"];
|
|
121
|
-
|
|
121
|
+
|
|
122
122
|
// Populate the OnMapPressCoordinate struct
|
|
123
123
|
facebook::react::RNMapsMapViewEventEmitter::OnPressCoordinate coordinate = {
|
|
124
124
|
.latitude = [coordinateDict[@"latitude"] doubleValue],
|
|
125
125
|
.longitude = [coordinateDict[@"longitude"] doubleValue],
|
|
126
126
|
};
|
|
127
|
-
|
|
127
|
+
|
|
128
128
|
// Populate the OnMapPressPosition struct
|
|
129
129
|
facebook::react::RNMapsMapViewEventEmitter::OnPressPosition position = {
|
|
130
130
|
.x = [positionDict[@"x"] doubleValue],
|
|
131
131
|
.y = [positionDict[@"y"] doubleValue],
|
|
132
132
|
};
|
|
133
|
-
|
|
133
|
+
|
|
134
134
|
auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
|
|
135
135
|
facebook::react::RNMapsMapViewEventEmitter::OnPress data = {
|
|
136
136
|
.action = std::string([@"press" UTF8String]),
|
|
@@ -140,11 +140,11 @@ using namespace facebook::react;
|
|
|
140
140
|
mapViewEventEmitter->onPress(data);
|
|
141
141
|
}
|
|
142
142
|
};
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
|
|
144
|
+
|
|
145
145
|
_view.onMapReady = [self](NSDictionary* dictionary) {
|
|
146
146
|
if (_eventEmitter) {
|
|
147
|
-
|
|
147
|
+
|
|
148
148
|
auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
|
|
149
149
|
facebook::react::RNMapsMapViewEventEmitter::OnMapReady data = {};
|
|
150
150
|
mapViewEventEmitter->onMapReady(data);
|
|
@@ -152,7 +152,7 @@ using namespace facebook::react;
|
|
|
152
152
|
};
|
|
153
153
|
_view.onChange = [self](NSDictionary* dictionary) {
|
|
154
154
|
if (_eventEmitter) {
|
|
155
|
-
|
|
155
|
+
|
|
156
156
|
NSDictionary* regionDict = dictionary[@"region"];
|
|
157
157
|
auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
|
|
158
158
|
facebook::react::RNMapsMapViewEventEmitter::OnRegionChange data = {
|
|
@@ -167,23 +167,23 @@ using namespace facebook::react;
|
|
|
167
167
|
};
|
|
168
168
|
_view.onDoublePress = [self](NSDictionary* dictionary) {
|
|
169
169
|
if (_eventEmitter) {
|
|
170
|
-
|
|
170
|
+
|
|
171
171
|
NSDictionary* coordinateDict = dictionary[@"coordinate"];
|
|
172
172
|
NSDictionary* positionDict = dictionary[@"position"];
|
|
173
|
-
|
|
173
|
+
|
|
174
174
|
// Populate the OnMapPressCoordinate struct
|
|
175
175
|
facebook::react::RNMapsMapViewEventEmitter::OnDoublePressCoordinate coordinate = {
|
|
176
176
|
.latitude = [coordinateDict[@"latitude"] doubleValue],
|
|
177
177
|
.longitude = [coordinateDict[@"longitude"] doubleValue],
|
|
178
178
|
};
|
|
179
|
-
|
|
179
|
+
|
|
180
180
|
// Populate the OnMapDouplePressPosition struct
|
|
181
181
|
facebook::react::RNMapsMapViewEventEmitter::OnDoublePressPosition position = {
|
|
182
182
|
.x = [positionDict[@"x"] doubleValue],
|
|
183
183
|
.y = [positionDict[@"y"] doubleValue],
|
|
184
184
|
};
|
|
185
|
-
|
|
186
|
-
|
|
185
|
+
|
|
186
|
+
|
|
187
187
|
auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
|
|
188
188
|
facebook::react::RNMapsMapViewEventEmitter::OnDoublePress data = {
|
|
189
189
|
.position = position,
|
|
@@ -192,25 +192,25 @@ using namespace facebook::react;
|
|
|
192
192
|
mapViewEventEmitter->onDoublePress(data);
|
|
193
193
|
}
|
|
194
194
|
};
|
|
195
|
-
|
|
195
|
+
|
|
196
196
|
_view.onPanDrag = [self](NSDictionary* dictionary) {
|
|
197
197
|
if (_eventEmitter) {
|
|
198
|
-
|
|
198
|
+
|
|
199
199
|
NSDictionary* coordinateDict = dictionary[@"coordinate"];
|
|
200
200
|
NSDictionary* positionDict = dictionary[@"position"];
|
|
201
|
-
|
|
201
|
+
|
|
202
202
|
// Populate the OnMapPressCoordinate struct
|
|
203
203
|
facebook::react::RNMapsMapViewEventEmitter::OnPanDragCoordinate coordinate = {
|
|
204
204
|
.latitude = [coordinateDict[@"latitude"] doubleValue],
|
|
205
205
|
.longitude = [coordinateDict[@"longitude"] doubleValue],
|
|
206
206
|
};
|
|
207
|
-
|
|
207
|
+
|
|
208
208
|
// Populate the OnMapDouplePressPosition struct
|
|
209
209
|
facebook::react::RNMapsMapViewEventEmitter::OnPanDragPosition position = {
|
|
210
210
|
.x = [positionDict[@"x"] doubleValue],
|
|
211
211
|
.y = [positionDict[@"y"] doubleValue],
|
|
212
212
|
};
|
|
213
|
-
|
|
213
|
+
|
|
214
214
|
auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
|
|
215
215
|
facebook::react::RNMapsMapViewEventEmitter::OnPanDrag data = {
|
|
216
216
|
.position = position,
|
|
@@ -219,14 +219,14 @@ using namespace facebook::react;
|
|
|
219
219
|
mapViewEventEmitter->onPanDrag(data);
|
|
220
220
|
}
|
|
221
221
|
};
|
|
222
|
-
|
|
222
|
+
|
|
223
223
|
_view.onUserLocationChange = [self](NSDictionary* dictionary) {
|
|
224
224
|
if (_eventEmitter) {
|
|
225
|
-
|
|
225
|
+
|
|
226
226
|
NSDictionary* coordinateDict = dictionary[@"coordinate"];
|
|
227
227
|
NSDictionary* errorDict = dictionary[@"error"];
|
|
228
|
-
|
|
229
|
-
|
|
228
|
+
|
|
229
|
+
|
|
230
230
|
// Populate the OnMapPressCoordinate struct
|
|
231
231
|
facebook::react::RNMapsMapViewEventEmitter::OnUserLocationChangeCoordinate coordinate = {
|
|
232
232
|
.latitude = [coordinateDict[@"latitude"] doubleValue],
|
|
@@ -236,12 +236,12 @@ using namespace facebook::react;
|
|
|
236
236
|
if (errorDict){
|
|
237
237
|
str = errorDict[@"message"];
|
|
238
238
|
}
|
|
239
|
-
|
|
239
|
+
|
|
240
240
|
facebook::react::RNMapsMapViewEventEmitter::OnUserLocationChangeError error = {
|
|
241
241
|
.message = std::string([str UTF8String]),
|
|
242
242
|
};
|
|
243
|
-
|
|
244
|
-
|
|
243
|
+
|
|
244
|
+
|
|
245
245
|
auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
|
|
246
246
|
facebook::react::RNMapsMapViewEventEmitter::OnUserLocationChange data = {
|
|
247
247
|
.coordinate = coordinate,
|
|
@@ -250,27 +250,27 @@ using namespace facebook::react;
|
|
|
250
250
|
mapViewEventEmitter->onUserLocationChange(data);
|
|
251
251
|
}
|
|
252
252
|
};
|
|
253
|
-
|
|
253
|
+
|
|
254
254
|
_view.onCalloutPress = [self](NSDictionary* dictionary) {
|
|
255
255
|
if (_eventEmitter) {
|
|
256
|
-
|
|
256
|
+
|
|
257
257
|
NSDictionary* coordinateDict = dictionary[@"coordinate"];
|
|
258
258
|
NSDictionary* positionDict = dictionary[@"position"];
|
|
259
|
-
|
|
259
|
+
|
|
260
260
|
// Populate the OnCalloutPressPoint struct
|
|
261
261
|
facebook::react::RNMapsMapViewEventEmitter::OnCalloutPressPoint point = {
|
|
262
262
|
.x = [coordinateDict[@"x"] doubleValue],
|
|
263
263
|
.y = [coordinateDict[@"y"] doubleValue],
|
|
264
264
|
};
|
|
265
|
-
|
|
266
|
-
|
|
265
|
+
|
|
266
|
+
|
|
267
267
|
facebook::react::RNMapsMapViewEventEmitter::OnCalloutPressFrame frame = {
|
|
268
268
|
.x = [positionDict[@"x"] doubleValue],
|
|
269
269
|
.y = [positionDict[@"y"] doubleValue],
|
|
270
270
|
.width = [positionDict[@"width"] doubleValue],
|
|
271
271
|
.height = [positionDict[@"height"] doubleValue],
|
|
272
272
|
};
|
|
273
|
-
|
|
273
|
+
|
|
274
274
|
auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
|
|
275
275
|
facebook::react::RNMapsMapViewEventEmitter::OnCalloutPress data = {
|
|
276
276
|
.action = std::string([dictionary[@"action"] UTF8String]),
|
|
@@ -281,11 +281,11 @@ using namespace facebook::react;
|
|
|
281
281
|
mapViewEventEmitter->onCalloutPress(data);
|
|
282
282
|
}
|
|
283
283
|
};
|
|
284
|
-
|
|
285
|
-
|
|
284
|
+
|
|
285
|
+
|
|
286
286
|
_view.onRegionChangeStart = [self](NSDictionary* dictionary) {
|
|
287
287
|
if (_eventEmitter) {
|
|
288
|
-
|
|
288
|
+
|
|
289
289
|
NSDictionary* regionDict = dictionary[@"region"];
|
|
290
290
|
auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
|
|
291
291
|
facebook::react::RNMapsMapViewEventEmitter::OnRegionChangeStart data = {
|
|
@@ -298,8 +298,8 @@ using namespace facebook::react;
|
|
|
298
298
|
mapViewEventEmitter->onRegionChangeStart(data);
|
|
299
299
|
}
|
|
300
300
|
};
|
|
301
|
-
|
|
302
|
-
|
|
301
|
+
|
|
302
|
+
|
|
303
303
|
#define HANDLE_MARKER_DRAG_EVENT(eventName, emitterFunction) \
|
|
304
304
|
if (_eventEmitter) { \
|
|
305
305
|
NSDictionary* coordinateDict = dictionary[@"coordinate"]; \
|
|
@@ -312,9 +312,9 @@ facebook::react::RNMapsMapViewEventEmitter::eventName data = { \
|
|
|
312
312
|
}; \
|
|
313
313
|
mapViewEventEmitter->emitterFunction(data); \
|
|
314
314
|
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
|
|
318
318
|
#define HANDLE_MARKER_EVENT(eventName, emitterFunction, actionName) \
|
|
319
319
|
if (_eventEmitter) { \
|
|
320
320
|
NSDictionary* coordinateDict = dictionary[@"coordinate"]; \
|
|
@@ -332,27 +332,27 @@ facebook::react::RNMapsMapViewEventEmitter::eventName data = { \
|
|
|
332
332
|
}; \
|
|
333
333
|
mapViewEventEmitter->emitterFunction(data); \
|
|
334
334
|
}
|
|
335
|
-
|
|
335
|
+
|
|
336
336
|
_view.onMarkerDrag = [self](NSDictionary* dictionary) {
|
|
337
337
|
HANDLE_MARKER_DRAG_EVENT(OnMarkerDrag, onMarkerDrag);
|
|
338
338
|
};
|
|
339
|
-
|
|
339
|
+
|
|
340
340
|
_view.onMarkerDragStart = [self](NSDictionary* dictionary) {
|
|
341
341
|
HANDLE_MARKER_DRAG_EVENT(OnMarkerDragStart, onMarkerDragStart);
|
|
342
342
|
};
|
|
343
|
-
|
|
343
|
+
|
|
344
344
|
_view.onMarkerDragEnd = [self](NSDictionary* dictionary) {
|
|
345
345
|
HANDLE_MARKER_DRAG_EVENT(OnMarkerDragEnd, onMarkerDragEnd);
|
|
346
346
|
};
|
|
347
|
-
|
|
347
|
+
|
|
348
348
|
_view.onMarkerSelect = [self](NSDictionary* dictionary) {
|
|
349
349
|
HANDLE_MARKER_EVENT(OnMarkerSelect, onMarkerSelect, "marker-select");
|
|
350
350
|
};
|
|
351
|
-
|
|
351
|
+
|
|
352
352
|
_view.onMarkerDeselect = [self](NSDictionary* dictionary) {
|
|
353
353
|
HANDLE_MARKER_EVENT(OnMarkerDeselect, onMarkerDeselect, "marker-deselect");
|
|
354
354
|
};
|
|
355
|
-
|
|
355
|
+
|
|
356
356
|
_view.onMarkerPress = [self](NSDictionary* dictionary) {
|
|
357
357
|
HANDLE_MARKER_EVENT(OnMarkerPress, onMarkerPress, "marker-press");
|
|
358
358
|
};
|
|
@@ -362,7 +362,7 @@ mapViewEventEmitter->emitterFunction(data); \
|
|
|
362
362
|
if (self = [super initWithFrame:frame]) {
|
|
363
363
|
[self prepareMapView];
|
|
364
364
|
}
|
|
365
|
-
|
|
365
|
+
|
|
366
366
|
return self;
|
|
367
367
|
}
|
|
368
368
|
|
|
@@ -403,28 +403,28 @@ MKMapType mapRNTypeToMKMapType(RNMapsMapViewMapType rnMapType) {
|
|
|
403
403
|
[self prepareMapView];
|
|
404
404
|
const auto &oldViewProps = *std::static_pointer_cast<RNMapsMapViewProps const>(_props);
|
|
405
405
|
const auto &newViewProps = *std::static_pointer_cast<RNMapsMapViewProps const>(props);
|
|
406
|
-
|
|
406
|
+
|
|
407
407
|
#define REMAP_MAPVIEW_PROP(name) \
|
|
408
408
|
if (oldViewProps.name != newViewProps.name) { \
|
|
409
409
|
_view.name = newViewProps.name; \
|
|
410
410
|
}
|
|
411
|
-
|
|
411
|
+
|
|
412
412
|
#define REMAP_MAPVIEW_STRING_PROP(name) \
|
|
413
413
|
if (oldViewProps.name != newViewProps.name) { \
|
|
414
414
|
_view.name = RCTNSStringFromString(newViewProps.name); \
|
|
415
415
|
}
|
|
416
|
-
|
|
416
|
+
|
|
417
417
|
#define REMAP_MAPVIEW_COLOR_PROP(name) \
|
|
418
418
|
if (oldViewProps.name != newViewProps.name) { \
|
|
419
419
|
_view.name = RCTUIColorFromSharedColor(newViewProps.name); \
|
|
420
420
|
}
|
|
421
|
-
|
|
421
|
+
|
|
422
422
|
#define REMAP_MAPVIEW_POINT_PROP(name) \
|
|
423
423
|
if (newViewProps.name.x != oldViewProps.name.x || \
|
|
424
424
|
newViewProps.name.y != oldViewProps.name.y) { \
|
|
425
425
|
_view.name = CGPointMake(newViewProps.name.x, newViewProps.name.y); \
|
|
426
426
|
}
|
|
427
|
-
|
|
427
|
+
|
|
428
428
|
#define REMAP_MAPVIEW_REGION_PROP(name) \
|
|
429
429
|
if (newViewProps.name.latitude != oldViewProps.name.latitude || \
|
|
430
430
|
newViewProps.name.longitude != oldViewProps.name.longitude || \
|
|
@@ -437,7 +437,7 @@ newViewProps.name.latitude, newViewProps.name.longitude), span); \
|
|
|
437
437
|
_view.name = region; \
|
|
438
438
|
[_view didSetRegion]; \
|
|
439
439
|
}
|
|
440
|
-
|
|
440
|
+
|
|
441
441
|
#define REMAP_MAPVIEW_CAMERA_PROP(name) \
|
|
442
442
|
if (newViewProps.name.center.latitude != oldViewProps.name.center.latitude || \
|
|
443
443
|
newViewProps.name.center.longitude != oldViewProps.name.center.longitude || \
|
|
@@ -452,7 +452,7 @@ camera.heading = newViewProps.name.heading; \
|
|
|
452
452
|
camera.pitch = newViewProps.name.pitch; \
|
|
453
453
|
_view.name = camera; \
|
|
454
454
|
}
|
|
455
|
-
|
|
455
|
+
|
|
456
456
|
#define REMAP_MAPVIEW_EDGEINSETS_PROP(name) \
|
|
457
457
|
if (newViewProps.name.top != oldViewProps.name.top || \
|
|
458
458
|
newViewProps.name.right != oldViewProps.name.right || \
|
|
@@ -463,49 +463,56 @@ newViewProps.name.left, \
|
|
|
463
463
|
newViewProps.name.bottom, \
|
|
464
464
|
newViewProps.name.right); \
|
|
465
465
|
}
|
|
466
|
-
|
|
466
|
+
|
|
467
467
|
#define REMAP_MAPVIEW_MAPTYPE(rnMapType) MKMapType##rnMapType
|
|
468
|
-
|
|
469
|
-
|
|
468
|
+
|
|
469
|
+
|
|
470
470
|
REMAP_MAPVIEW_PROP(cacheEnabled)
|
|
471
|
-
|
|
471
|
+
|
|
472
472
|
REMAP_MAPVIEW_PROP(followsUserLocation)
|
|
473
473
|
REMAP_MAPVIEW_PROP(loadingEnabled)
|
|
474
|
+
if (_view.scrollEnabled != newViewProps.scrollEnabled){
|
|
475
|
+
[_view setScrollEnabled:newViewProps.scrollEnabled];
|
|
476
|
+
}
|
|
477
|
+
if (_view.handlePanDrag != newViewProps.handlePanDrag){
|
|
478
|
+
[_view setHandlePanDrag:newViewProps.handlePanDrag];
|
|
479
|
+
}
|
|
480
|
+
|
|
474
481
|
REMAP_MAPVIEW_PROP(scrollEnabled)
|
|
475
|
-
|
|
482
|
+
|
|
476
483
|
REMAP_MAPVIEW_PROP(maxDelta)
|
|
477
484
|
REMAP_MAPVIEW_PROP(maxZoom)
|
|
478
485
|
REMAP_MAPVIEW_PROP(minDelta)
|
|
479
486
|
REMAP_MAPVIEW_PROP(minZoom)
|
|
480
|
-
|
|
487
|
+
|
|
481
488
|
REMAP_MAPVIEW_PROP(showsCompass)
|
|
482
489
|
REMAP_MAPVIEW_PROP(showsScale)
|
|
483
490
|
REMAP_MAPVIEW_PROP(showsTraffic)
|
|
484
491
|
REMAP_MAPVIEW_PROP(showsUserLocation)
|
|
485
492
|
REMAP_MAPVIEW_PROP(userLocationCalloutEnabled)
|
|
486
493
|
REMAP_MAPVIEW_PROP(zoomEnabled)
|
|
487
|
-
|
|
494
|
+
|
|
488
495
|
REMAP_MAPVIEW_POINT_PROP(compassOffset)
|
|
489
|
-
|
|
496
|
+
|
|
490
497
|
if (![_view ignoreRegionChanges]){
|
|
491
498
|
_view.ignoreRegionChanges = YES;
|
|
492
499
|
REMAP_MAPVIEW_REGION_PROP(initialRegion)
|
|
493
500
|
REMAP_MAPVIEW_REGION_PROP(region)
|
|
494
501
|
_view.ignoreRegionChanges = NO;
|
|
495
502
|
}
|
|
496
|
-
|
|
503
|
+
|
|
497
504
|
REMAP_MAPVIEW_CAMERA_PROP(initialCamera)
|
|
498
505
|
REMAP_MAPVIEW_CAMERA_PROP(camera)
|
|
499
|
-
|
|
506
|
+
|
|
500
507
|
REMAP_MAPVIEW_EDGEINSETS_PROP(legalLabelInsets)
|
|
501
508
|
REMAP_MAPVIEW_EDGEINSETS_PROP(mapPadding)
|
|
502
|
-
|
|
509
|
+
|
|
503
510
|
REMAP_MAPVIEW_COLOR_PROP(loadingIndicatorColor)
|
|
504
511
|
REMAP_MAPVIEW_COLOR_PROP(loadingIndicatorColor)
|
|
505
512
|
REMAP_MAPVIEW_COLOR_PROP(tintColor)
|
|
506
|
-
|
|
513
|
+
|
|
507
514
|
REMAP_MAPVIEW_STRING_PROP(userLocationAnnotationTitle)
|
|
508
|
-
|
|
515
|
+
|
|
509
516
|
if (oldViewProps.mapType != newViewProps.mapType){
|
|
510
517
|
_view.mapType = mapRNTypeToMKMapType(newViewProps.mapType);
|
|
511
518
|
}
|
|
@@ -522,16 +529,16 @@ newViewProps.name.right); \
|
|
|
522
529
|
break;
|
|
523
530
|
}
|
|
524
531
|
}
|
|
525
|
-
|
|
532
|
+
|
|
526
533
|
if (oldViewProps.cameraZoomRange.minCenterCoordinateDistance != newViewProps.cameraZoomRange.minCenterCoordinateDistance ||
|
|
527
534
|
oldViewProps.cameraZoomRange.maxCenterCoordinateDistance != newViewProps.cameraZoomRange.maxCenterCoordinateDistance ||
|
|
528
535
|
oldViewProps.cameraZoomRange.animated != newViewProps.cameraZoomRange.animated) {
|
|
529
|
-
|
|
536
|
+
|
|
530
537
|
MKMapCameraZoomRange* zoomRange = [[MKMapCameraZoomRange alloc] initWithMinCenterCoordinateDistance:newViewProps.cameraZoomRange.minCenterCoordinateDistance maxCenterCoordinateDistance:newViewProps.cameraZoomRange.maxCenterCoordinateDistance];
|
|
531
538
|
[_view setCameraZoomRange:zoomRange animated:newViewProps.cameraZoomRange.animated];
|
|
532
539
|
}
|
|
533
|
-
|
|
534
|
-
|
|
540
|
+
|
|
541
|
+
|
|
535
542
|
[super updateProps:props oldProps:oldProps];
|
|
536
543
|
}
|
|
537
544
|
|
package/lib/MapView.js
CHANGED
|
@@ -374,7 +374,12 @@ class MapView extends React.Component {
|
|
|
374
374
|
longitudeDelta: this.props.region.longitudeDelta,
|
|
375
375
|
};
|
|
376
376
|
}
|
|
377
|
-
if (
|
|
377
|
+
if (this.state.isReady) {
|
|
378
|
+
if (props.onPanDrag) {
|
|
379
|
+
props.handlePanDrag = !!props.onPanDrag;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
else {
|
|
378
383
|
props.style = this.props.style;
|
|
379
384
|
props.initialCamera = this.props.initialCamera;
|
|
380
385
|
props.onLayout = this.props.onLayout;
|
|
@@ -412,12 +417,7 @@ class MapView extends React.Component {
|
|
|
412
417
|
: undefined,
|
|
413
418
|
...this.props,
|
|
414
419
|
};
|
|
415
|
-
if (this.state.isReady) {
|
|
416
|
-
if (props.onPanDrag) {
|
|
417
|
-
props.handlePanDrag = !!props.onPanDrag;
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
else {
|
|
420
|
+
if (!this.state.isReady) {
|
|
421
421
|
props.style = this.props.style;
|
|
422
422
|
props.initialCamera = this.props.initialCamera;
|
|
423
423
|
props.onLayout = this.props.onLayout;
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.googleMapIsInstalled = exports.createNotSupportedComponent = exports.getNativeMapName = exports.ProviderContext = exports.NOT_SUPPORTED = exports.USES_DEFAULT_IMPLEMENTATION = exports.SUPPORTED = void 0;
|
|
4
7
|
const react_1 = require("react");
|
|
5
8
|
const react_native_1 = require("react-native");
|
|
6
9
|
const ProviderConstants_1 = require("./ProviderConstants");
|
|
10
|
+
const NativeComponentGooglePolygon_1 = __importDefault(require("./specs/NativeComponentGooglePolygon"));
|
|
7
11
|
exports.SUPPORTED = 'SUPPORTED';
|
|
8
12
|
exports.USES_DEFAULT_IMPLEMENTATION = 'USES_DEFAULT_IMPLEMENTATION';
|
|
9
13
|
exports.NOT_SUPPORTED = 'NOT_SUPPORTED';
|
|
@@ -47,6 +51,13 @@ function decorateMapComponent(Component, componentName, providers) {
|
|
|
47
51
|
if (react_native_1.Platform.OS !== 'android' && react_native_1.Platform.OS !== 'ios') {
|
|
48
52
|
throw new Error(`react-native-maps doesn't support ${react_native_1.Platform.OS}`);
|
|
49
53
|
}
|
|
54
|
+
if (componentName === 'Polygon' &&
|
|
55
|
+
provider === ProviderConstants_1.PROVIDER_GOOGLE &&
|
|
56
|
+
react_native_1.Platform.OS === 'ios' &&
|
|
57
|
+
exports.googleMapIsInstalled) {
|
|
58
|
+
// @ts-ignore
|
|
59
|
+
return NativeComponentGooglePolygon_1.default;
|
|
60
|
+
}
|
|
50
61
|
const platformSupport = providerInfo[react_native_1.Platform.OS];
|
|
51
62
|
const nativeComponentName = getNativeComponentName(provider, componentName);
|
|
52
63
|
if (platformSupport === exports.NOT_SUPPORTED) {
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { HostComponent, ViewProps, ColorValue } from 'react-native';
|
|
2
|
+
import { Double, BubblingEventHandler } from 'react-native/Libraries/Types/CodegenTypes';
|
|
3
|
+
export type LatLng = Readonly<{
|
|
4
|
+
latitude: Double;
|
|
5
|
+
longitude: Double;
|
|
6
|
+
}>;
|
|
7
|
+
export type PolygonPressEventHandler = BubblingEventHandler<Readonly<{
|
|
8
|
+
action?: string;
|
|
9
|
+
id: string;
|
|
10
|
+
coordinate: {
|
|
11
|
+
latitude: Double;
|
|
12
|
+
longitude: Double;
|
|
13
|
+
};
|
|
14
|
+
position?: {
|
|
15
|
+
x: Double;
|
|
16
|
+
y: Double;
|
|
17
|
+
};
|
|
18
|
+
}>>;
|
|
19
|
+
export interface PolygonFabricNativeProps extends ViewProps {
|
|
20
|
+
/**
|
|
21
|
+
* An array of coordinates to describe the polygon
|
|
22
|
+
*
|
|
23
|
+
* @platform iOS: Supported
|
|
24
|
+
* @platform Android: Supported
|
|
25
|
+
*/
|
|
26
|
+
coordinates: ReadonlyArray<LatLng>;
|
|
27
|
+
/**
|
|
28
|
+
* The fill color to use for the path.
|
|
29
|
+
*
|
|
30
|
+
* @default `#000`, `rgba(r,g,b,0.5)`
|
|
31
|
+
* @platform iOS: Supported
|
|
32
|
+
* @platform Android: Supported
|
|
33
|
+
*/
|
|
34
|
+
fillColor?: ColorValue;
|
|
35
|
+
/**
|
|
36
|
+
* The stroke color to use for the path.
|
|
37
|
+
*
|
|
38
|
+
* @default `#000`, `rgba(r,g,b,0.5)`
|
|
39
|
+
* @platform iOS: Supported
|
|
40
|
+
* @platform Android: Supported
|
|
41
|
+
*/
|
|
42
|
+
strokeColor?: ColorValue;
|
|
43
|
+
/**
|
|
44
|
+
* Boolean to indicate whether to draw each segment of the line as a geodesic as opposed to straight lines on the Mercator projection.
|
|
45
|
+
* A geodesic is the shortest path between two points on the Earth's surface.
|
|
46
|
+
* The geodesic curve is constructed assuming the Earth is a sphere.
|
|
47
|
+
*
|
|
48
|
+
* @platform iOS: Google Maps only
|
|
49
|
+
* @platform Android: Supported
|
|
50
|
+
*/
|
|
51
|
+
geodesic?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* A 2d array of coordinates to describe holes of the polygon where each hole has at least 3 points.
|
|
54
|
+
*
|
|
55
|
+
* @platform iOS: Supported
|
|
56
|
+
* @platform Android: Supported
|
|
57
|
+
*/
|
|
58
|
+
holes?: ReadonlyArray<ReadonlyArray<LatLng>>;
|
|
59
|
+
/**
|
|
60
|
+
* Boolean to allow a polygon to be tappable and use the onPress function.
|
|
61
|
+
*
|
|
62
|
+
* @platform iOS: Google Maps only
|
|
63
|
+
* @platform Android: Supported
|
|
64
|
+
*/
|
|
65
|
+
tappable?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Callback that is called when user taps on the map.
|
|
68
|
+
*
|
|
69
|
+
* @platform iOS: Supported
|
|
70
|
+
* @platform Android: Supported
|
|
71
|
+
*/
|
|
72
|
+
onPress?: PolygonPressEventHandler;
|
|
73
|
+
}
|
|
74
|
+
declare const _default: HostComponent<PolygonFabricNativeProps>;
|
|
75
|
+
export default _default;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const codegenNativeComponent_1 = __importDefault(require("react-native/Libraries/Utilities/codegenNativeComponent"));
|
|
7
|
+
exports.default = (0, codegenNativeComponent_1.default)('RNMapsGooglePolygon', {
|
|
8
|
+
excludedPlatforms: ['android'],
|
|
9
|
+
});
|
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.16",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"lint": "eslint . --max-warnings 0",
|