react-native-maps 1.21.0-alpha.14 → 1.21.0-alpha.15
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 +31 -18
- package/ios/AirGoogleMaps/RNMapsGooglePolygonView.h +26 -0
- package/ios/AirGoogleMaps/RNMapsGooglePolygonView.mm +217 -0
- package/ios/AirGoogleMaps/RNMapsGooglePolygonViewManager.mm +25 -0
- package/lib/decorateMapComponent.js +11 -0
- package/lib/specs/NativeComponentGooglePolygon.d.ts +75 -0
- package/lib/specs/NativeComponentGooglePolygon.js +9 -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,11 @@ 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
|
+
|
|
508
521
|
if (newViewProps.minZoom != oldViewProps.minZoom || newViewProps.maxZoom != oldViewProps.maxZoom){
|
|
509
522
|
[_view setMinZoom:newViewProps.minZoom maxZoom:newViewProps.maxZoom];
|
|
510
523
|
}
|
|
@@ -530,8 +543,8 @@ using namespace facebook::react;
|
|
|
530
543
|
viewingAngle:newViewProps.camera.pitch];
|
|
531
544
|
_view.cameraProp = camera;
|
|
532
545
|
}
|
|
533
|
-
|
|
534
|
-
|
|
546
|
+
|
|
547
|
+
|
|
535
548
|
REMAP_MAPVIEW_EDGEINSETS_PROP(mapPadding)
|
|
536
549
|
|
|
537
550
|
|
|
@@ -554,7 +567,7 @@ using namespace facebook::react;
|
|
|
554
567
|
break;
|
|
555
568
|
}
|
|
556
569
|
}
|
|
557
|
-
|
|
570
|
+
|
|
558
571
|
if (oldViewProps.userInterfaceStyle != newViewProps.userInterfaceStyle){
|
|
559
572
|
switch (newViewProps.userInterfaceStyle) {
|
|
560
573
|
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
|
|
@@ -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.15",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"lint": "eslint . --max-warnings 0",
|