@lugg/maps 0.2.0-alpha.11 → 0.2.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/android/src/main/java/com/luggmaps/LuggGoogleMapView.kt +5 -11
- package/android/src/main/java/com/luggmaps/LuggMapWrapperView.kt +5 -5
- package/android/src/main/java/com/luggmaps/core/PolylineAnimator.kt +31 -16
- package/ios/LuggAppleMapView.mm +9 -9
- package/ios/core/GMSPolylineAnimator.m +40 -5
- package/ios/core/MKPolylineAnimator.m +48 -11
- package/lib/module/MapProvider.web.js +3 -0
- package/lib/module/MapProvider.web.js.map +1 -1
- package/lib/module/MapView.web.js +48 -33
- package/lib/module/MapView.web.js.map +1 -1
- package/lib/module/components/Polyline.web.js +3 -1
- package/lib/module/components/Polyline.web.js.map +1 -1
- package/lib/typescript/src/MapProvider.web.d.ts +2 -0
- package/lib/typescript/src/MapProvider.web.d.ts.map +1 -1
- package/lib/typescript/src/MapView.web.d.ts.map +1 -1
- package/lib/typescript/src/components/Polyline.web.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/MapProvider.web.tsx +5 -0
- package/src/MapView.web.tsx +42 -31
- package/src/components/Polyline.web.tsx +3 -1
|
@@ -54,8 +54,8 @@ class LuggGoogleMapView(private val reactContext: ThemedReactContext) :
|
|
|
54
54
|
private var isMapReady = false
|
|
55
55
|
private var isDragging = false
|
|
56
56
|
private var mapId: String = DEMO_MAP_ID
|
|
57
|
-
private val pendingMarkerViews =
|
|
58
|
-
private val pendingPolylineViews =
|
|
57
|
+
private val pendingMarkerViews = mutableSetOf<LuggMarkerView>()
|
|
58
|
+
private val pendingPolylineViews = mutableSetOf<LuggPolylineView>()
|
|
59
59
|
private val polylineAnimators = mutableMapOf<LuggPolylineView, PolylineAnimator>()
|
|
60
60
|
|
|
61
61
|
// Initial camera settings
|
|
@@ -236,9 +236,7 @@ class LuggGoogleMapView(private val reactContext: ThemedReactContext) :
|
|
|
236
236
|
|
|
237
237
|
override fun markerViewDidLayout(markerView: LuggMarkerView) {
|
|
238
238
|
if (googleMap == null) {
|
|
239
|
-
|
|
240
|
-
pendingMarkerViews.add(markerView)
|
|
241
|
-
}
|
|
239
|
+
pendingMarkerViews.add(markerView)
|
|
242
240
|
return
|
|
243
241
|
}
|
|
244
242
|
|
|
@@ -261,9 +259,7 @@ class LuggGoogleMapView(private val reactContext: ThemedReactContext) :
|
|
|
261
259
|
|
|
262
260
|
private fun syncMarkerView(markerView: LuggMarkerView) {
|
|
263
261
|
if (googleMap == null) {
|
|
264
|
-
|
|
265
|
-
pendingMarkerViews.add(markerView)
|
|
266
|
-
}
|
|
262
|
+
pendingMarkerViews.add(markerView)
|
|
267
263
|
return
|
|
268
264
|
}
|
|
269
265
|
|
|
@@ -326,9 +322,7 @@ class LuggGoogleMapView(private val reactContext: ThemedReactContext) :
|
|
|
326
322
|
|
|
327
323
|
private fun syncPolylineView(polylineView: LuggPolylineView) {
|
|
328
324
|
if (googleMap == null) {
|
|
329
|
-
|
|
330
|
-
pendingPolylineViews.add(polylineView)
|
|
331
|
-
}
|
|
325
|
+
pendingPolylineViews.add(polylineView)
|
|
332
326
|
return
|
|
333
327
|
}
|
|
334
328
|
|
|
@@ -26,14 +26,14 @@ class LuggMapWrapperView(context: ThemedReactContext) : ReactViewGroup(context)
|
|
|
26
26
|
bottom: Int
|
|
27
27
|
) {
|
|
28
28
|
super.onLayout(changed, left, top, right, bottom)
|
|
29
|
-
val
|
|
30
|
-
val
|
|
29
|
+
val w = right - left
|
|
30
|
+
val h = bottom - top
|
|
31
31
|
getChildAt(0)?.let {
|
|
32
32
|
it.measure(
|
|
33
|
-
MeasureSpec.makeMeasureSpec(
|
|
34
|
-
MeasureSpec.makeMeasureSpec(
|
|
33
|
+
MeasureSpec.makeMeasureSpec(w, MeasureSpec.EXACTLY),
|
|
34
|
+
MeasureSpec.makeMeasureSpec(h, MeasureSpec.EXACTLY)
|
|
35
35
|
)
|
|
36
|
-
it.layout(0, 0,
|
|
36
|
+
it.layout(0, 0, w, h)
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
}
|
|
@@ -40,6 +40,10 @@ class PolylineAnimator {
|
|
|
40
40
|
private var cumulativeDistances: FloatArray = floatArrayOf()
|
|
41
41
|
private var totalLength: Float = 0f
|
|
42
42
|
|
|
43
|
+
// Reusable collections to avoid per-frame allocations
|
|
44
|
+
private val reusablePoints = ArrayList<LatLng>()
|
|
45
|
+
private val reusableSpans = ArrayList<StyleSpan>()
|
|
46
|
+
|
|
43
47
|
fun update() {
|
|
44
48
|
if (animated) return
|
|
45
49
|
|
|
@@ -97,12 +101,19 @@ class PolylineAnimator {
|
|
|
97
101
|
}
|
|
98
102
|
|
|
99
103
|
private fun indexForDistance(distance: Float): Int {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
104
|
+
var left = 0
|
|
105
|
+
var right = cumulativeDistances.size - 1
|
|
106
|
+
|
|
107
|
+
while (left < right) {
|
|
108
|
+
val mid = (left + right + 1) / 2
|
|
109
|
+
if (cumulativeDistances[mid] <= distance) {
|
|
110
|
+
left = mid
|
|
111
|
+
} else {
|
|
112
|
+
right = mid - 1
|
|
103
113
|
}
|
|
104
114
|
}
|
|
105
|
-
|
|
115
|
+
|
|
116
|
+
return left.coerceAtMost(cumulativeDistances.size - 2).coerceAtLeast(0)
|
|
106
117
|
}
|
|
107
118
|
|
|
108
119
|
private fun coordinateAtDistance(distance: Float): LatLng {
|
|
@@ -118,6 +129,9 @@ class PolylineAnimator {
|
|
|
118
129
|
val c1 = coordinates[idx]
|
|
119
130
|
val c2 = coordinates[idx + 1]
|
|
120
131
|
|
|
132
|
+
// Reuse existing coordinate if no interpolation needed
|
|
133
|
+
if (t == 0f) return c1
|
|
134
|
+
|
|
121
135
|
return LatLng(
|
|
122
136
|
c1.latitude + (c2.latitude - c1.latitude) * t,
|
|
123
137
|
c1.longitude + (c2.longitude - c1.longitude) * t
|
|
@@ -160,31 +174,32 @@ class PolylineAnimator {
|
|
|
160
174
|
val startIndex = indexForDistance(tailDist)
|
|
161
175
|
val endIndex = indexForDistance(headDist)
|
|
162
176
|
|
|
163
|
-
|
|
164
|
-
|
|
177
|
+
reusablePoints.clear()
|
|
178
|
+
reusableSpans.clear()
|
|
165
179
|
|
|
166
|
-
|
|
180
|
+
reusablePoints.add(coordinateAtDistance(tailDist))
|
|
167
181
|
|
|
168
182
|
for (i in (startIndex + 1)..endIndex) {
|
|
169
|
-
|
|
183
|
+
reusablePoints.add(coordinates[i])
|
|
170
184
|
}
|
|
171
185
|
|
|
172
186
|
val endCoord = coordinateAtDistance(headDist)
|
|
173
|
-
val lastAdded =
|
|
187
|
+
val lastAdded = reusablePoints.lastOrNull()
|
|
174
188
|
if (lastAdded == null || endCoord.latitude != lastAdded.latitude || endCoord.longitude != lastAdded.longitude) {
|
|
175
|
-
|
|
189
|
+
reusablePoints.add(endCoord)
|
|
176
190
|
}
|
|
177
191
|
|
|
178
|
-
|
|
179
|
-
|
|
192
|
+
val pointCount = reusablePoints.size
|
|
193
|
+
for (i in 0 until (pointCount - 1)) {
|
|
194
|
+
val segMidDist = tailDist + visibleLength * (i + 0.5f) / (pointCount - 1)
|
|
180
195
|
val gradientPos = (segMidDist - tailDist) / visibleLength
|
|
181
196
|
val color = colorAtGradientPosition(gradientPos)
|
|
182
|
-
|
|
197
|
+
reusableSpans.add(StyleSpan(StrokeStyle.colorBuilder(color).build()))
|
|
183
198
|
}
|
|
184
199
|
|
|
185
|
-
poly.points =
|
|
186
|
-
if (
|
|
187
|
-
poly.setSpans(
|
|
200
|
+
poly.points = reusablePoints
|
|
201
|
+
if (reusableSpans.isNotEmpty()) {
|
|
202
|
+
poly.setSpans(reusableSpans)
|
|
188
203
|
}
|
|
189
204
|
}
|
|
190
205
|
|
package/ios/LuggAppleMapView.mm
CHANGED
|
@@ -44,6 +44,7 @@ using namespace luggmaps::events;
|
|
|
44
44
|
BOOL _isDragging;
|
|
45
45
|
double _minZoom;
|
|
46
46
|
double _maxZoom;
|
|
47
|
+
NSMapTable<id<MKOverlay>, LuggPolylineView *> *_overlayToPolylineMap;
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
+ (ComponentDescriptorProvider)componentDescriptorProvider {
|
|
@@ -56,6 +57,7 @@ using namespace luggmaps::events;
|
|
|
56
57
|
static const auto defaultProps =
|
|
57
58
|
std::make_shared<const LuggAppleMapViewProps>();
|
|
58
59
|
_props = defaultProps;
|
|
60
|
+
_overlayToPolylineMap = [NSMapTable strongToWeakObjectsMapTable];
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
return self;
|
|
@@ -111,6 +113,7 @@ using namespace luggmaps::events;
|
|
|
111
113
|
polylineView.delegate = nil;
|
|
112
114
|
MKPolyline *polyline = (MKPolyline *)polylineView.polyline;
|
|
113
115
|
if (polyline) {
|
|
116
|
+
[_overlayToPolylineMap removeObjectForKey:polyline];
|
|
114
117
|
[_mapView removeOverlay:polyline];
|
|
115
118
|
polylineView.polyline = nil;
|
|
116
119
|
}
|
|
@@ -302,6 +305,7 @@ using namespace luggmaps::events;
|
|
|
302
305
|
free(coords);
|
|
303
306
|
|
|
304
307
|
polylineView.polyline = polyline;
|
|
308
|
+
[_overlayToPolylineMap setObject:polylineView forKey:polyline];
|
|
305
309
|
[self insertOverlay:polyline withZIndex:polylineView.zIndex];
|
|
306
310
|
}
|
|
307
311
|
|
|
@@ -320,6 +324,7 @@ using namespace luggmaps::events;
|
|
|
320
324
|
renderer.animated = NO;
|
|
321
325
|
}
|
|
322
326
|
if (oldPolyline) {
|
|
327
|
+
[_overlayToPolylineMap removeObjectForKey:oldPolyline];
|
|
323
328
|
[_mapView removeOverlay:oldPolyline];
|
|
324
329
|
polylineView.polyline = nil;
|
|
325
330
|
polylineView.renderer = nil;
|
|
@@ -337,9 +342,11 @@ using namespace luggmaps::events;
|
|
|
337
342
|
free(coords);
|
|
338
343
|
|
|
339
344
|
polylineView.polyline = newPolyline;
|
|
345
|
+
[_overlayToPolylineMap setObject:polylineView forKey:newPolyline];
|
|
340
346
|
|
|
341
347
|
// If we have an existing renderer, update it in place
|
|
342
348
|
if (renderer && oldPolyline) {
|
|
349
|
+
[_overlayToPolylineMap removeObjectForKey:oldPolyline];
|
|
343
350
|
[_mapView removeOverlay:oldPolyline];
|
|
344
351
|
[self insertOverlay:newPolyline withZIndex:polylineView.zIndex];
|
|
345
352
|
[renderer updatePolyline:newPolyline];
|
|
@@ -353,6 +360,7 @@ using namespace luggmaps::events;
|
|
|
353
360
|
|
|
354
361
|
// Otherwise do full add
|
|
355
362
|
if (oldPolyline) {
|
|
363
|
+
[_overlayToPolylineMap removeObjectForKey:oldPolyline];
|
|
356
364
|
[_mapView removeOverlay:oldPolyline];
|
|
357
365
|
}
|
|
358
366
|
[self insertOverlay:newPolyline withZIndex:polylineView.zIndex];
|
|
@@ -380,15 +388,7 @@ using namespace luggmaps::events;
|
|
|
380
388
|
}
|
|
381
389
|
|
|
382
390
|
- (LuggPolylineView *)findPolylineViewForOverlay:(id<MKOverlay>)overlay {
|
|
383
|
-
|
|
384
|
-
if ([subview isKindOfClass:[LuggPolylineView class]]) {
|
|
385
|
-
LuggPolylineView *polylineView = (LuggPolylineView *)subview;
|
|
386
|
-
if (polylineView.polyline == overlay) {
|
|
387
|
-
return polylineView;
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
return nil;
|
|
391
|
+
return [_overlayToPolylineMap objectForKey:overlay];
|
|
392
392
|
}
|
|
393
393
|
|
|
394
394
|
#pragma mark - MarkerViewDelegate
|
|
@@ -1,8 +1,34 @@
|
|
|
1
1
|
#import "GMSPolylineAnimator.h"
|
|
2
2
|
#import <QuartzCore/QuartzCore.h>
|
|
3
3
|
|
|
4
|
+
@interface GMSDisplayLinkProxy : NSObject
|
|
5
|
+
@property(nonatomic, weak) id target;
|
|
6
|
+
@property(nonatomic, assign) SEL selector;
|
|
7
|
+
@end
|
|
8
|
+
|
|
9
|
+
@implementation GMSDisplayLinkProxy
|
|
10
|
+
- (instancetype)initWithTarget:(id)target selector:(SEL)selector {
|
|
11
|
+
if (self = [super init]) {
|
|
12
|
+
_target = target;
|
|
13
|
+
_selector = selector;
|
|
14
|
+
}
|
|
15
|
+
return self;
|
|
16
|
+
}
|
|
17
|
+
- (void)tick:(CADisplayLink *)displayLink {
|
|
18
|
+
if (_target) {
|
|
19
|
+
#pragma clang diagnostic push
|
|
20
|
+
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
|
|
21
|
+
[_target performSelector:_selector withObject:displayLink];
|
|
22
|
+
#pragma clang diagnostic pop
|
|
23
|
+
} else {
|
|
24
|
+
[displayLink invalidate];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
@end
|
|
28
|
+
|
|
4
29
|
@implementation GMSPolylineAnimator {
|
|
5
30
|
CADisplayLink *_displayLink;
|
|
31
|
+
GMSDisplayLinkProxy *_displayLinkProxy;
|
|
6
32
|
CGFloat _animationProgress;
|
|
7
33
|
NSArray<NSNumber *> *_cumulativeDistances;
|
|
8
34
|
CGFloat _totalLength;
|
|
@@ -39,7 +65,8 @@
|
|
|
39
65
|
}
|
|
40
66
|
[self computeCumulativeDistances];
|
|
41
67
|
_animationProgress = 0;
|
|
42
|
-
|
|
68
|
+
_displayLinkProxy = [[GMSDisplayLinkProxy alloc] initWithTarget:self selector:@selector(animationTick:)];
|
|
69
|
+
_displayLink = [CADisplayLink displayLinkWithTarget:_displayLinkProxy selector:@selector(tick:)];
|
|
43
70
|
[_displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
|
|
44
71
|
}
|
|
45
72
|
|
|
@@ -62,6 +89,7 @@
|
|
|
62
89
|
- (void)stopAnimation {
|
|
63
90
|
[_displayLink invalidate];
|
|
64
91
|
_displayLink = nil;
|
|
92
|
+
_displayLinkProxy = nil;
|
|
65
93
|
}
|
|
66
94
|
|
|
67
95
|
- (void)animationTick:(CADisplayLink *)displayLink {
|
|
@@ -98,12 +126,19 @@
|
|
|
98
126
|
}
|
|
99
127
|
|
|
100
128
|
- (NSUInteger)indexForDistance:(CGFloat)distance {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
129
|
+
NSUInteger left = 0;
|
|
130
|
+
NSUInteger right = _cumulativeDistances.count - 1;
|
|
131
|
+
|
|
132
|
+
while (left < right) {
|
|
133
|
+
NSUInteger mid = (left + right + 1) / 2;
|
|
134
|
+
if (_cumulativeDistances[mid].doubleValue <= distance) {
|
|
135
|
+
left = mid;
|
|
136
|
+
} else {
|
|
137
|
+
right = mid - 1;
|
|
104
138
|
}
|
|
105
139
|
}
|
|
106
|
-
|
|
140
|
+
|
|
141
|
+
return MIN(left, _cumulativeDistances.count - 2);
|
|
107
142
|
}
|
|
108
143
|
|
|
109
144
|
- (CLLocationCoordinate2D)coordinateAtDistance:(CGFloat)distance {
|
|
@@ -1,12 +1,39 @@
|
|
|
1
1
|
#import "MKPolylineAnimator.h"
|
|
2
2
|
#import <QuartzCore/QuartzCore.h>
|
|
3
3
|
|
|
4
|
+
@interface MKDisplayLinkProxy : NSObject
|
|
5
|
+
@property(nonatomic, weak) id target;
|
|
6
|
+
@property(nonatomic, assign) SEL selector;
|
|
7
|
+
@end
|
|
8
|
+
|
|
9
|
+
@implementation MKDisplayLinkProxy
|
|
10
|
+
- (instancetype)initWithTarget:(id)target selector:(SEL)selector {
|
|
11
|
+
if (self = [super init]) {
|
|
12
|
+
_target = target;
|
|
13
|
+
_selector = selector;
|
|
14
|
+
}
|
|
15
|
+
return self;
|
|
16
|
+
}
|
|
17
|
+
- (void)tick:(CADisplayLink *)displayLink {
|
|
18
|
+
if (_target) {
|
|
19
|
+
#pragma clang diagnostic push
|
|
20
|
+
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
|
|
21
|
+
[_target performSelector:_selector withObject:displayLink];
|
|
22
|
+
#pragma clang diagnostic pop
|
|
23
|
+
} else {
|
|
24
|
+
[displayLink invalidate];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
@end
|
|
28
|
+
|
|
4
29
|
@implementation MKPolylineAnimator {
|
|
5
30
|
MKPolyline *_polyline;
|
|
6
31
|
CADisplayLink *_displayLink;
|
|
32
|
+
MKDisplayLinkProxy *_displayLinkProxy;
|
|
7
33
|
CGFloat _animationProgress;
|
|
8
34
|
NSArray<NSNumber *> *_cumulativeDistances;
|
|
9
35
|
CGFloat _totalLength;
|
|
36
|
+
CGColorSpaceRef _colorSpace;
|
|
10
37
|
}
|
|
11
38
|
|
|
12
39
|
- (id)initWithPolyline:(MKPolyline *)polyline {
|
|
@@ -14,6 +41,7 @@
|
|
|
14
41
|
if (self) {
|
|
15
42
|
_polyline = polyline;
|
|
16
43
|
_animationProgress = 0;
|
|
44
|
+
_colorSpace = CGColorSpaceCreateDeviceRGB();
|
|
17
45
|
[self createPath];
|
|
18
46
|
}
|
|
19
47
|
return self;
|
|
@@ -21,6 +49,10 @@
|
|
|
21
49
|
|
|
22
50
|
- (void)dealloc {
|
|
23
51
|
[self stopAnimation];
|
|
52
|
+
if (_colorSpace) {
|
|
53
|
+
CGColorSpaceRelease(_colorSpace);
|
|
54
|
+
_colorSpace = NULL;
|
|
55
|
+
}
|
|
24
56
|
}
|
|
25
57
|
|
|
26
58
|
- (void)setAnimated:(BOOL)animated {
|
|
@@ -42,7 +74,8 @@
|
|
|
42
74
|
}
|
|
43
75
|
[self computeCumulativeDistances];
|
|
44
76
|
_animationProgress = 0;
|
|
45
|
-
|
|
77
|
+
_displayLinkProxy = [[MKDisplayLinkProxy alloc] initWithTarget:self selector:@selector(animationTick:)];
|
|
78
|
+
_displayLink = [CADisplayLink displayLinkWithTarget:_displayLinkProxy selector:@selector(tick:)];
|
|
46
79
|
[_displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
|
|
47
80
|
}
|
|
48
81
|
|
|
@@ -65,15 +98,23 @@
|
|
|
65
98
|
- (void)stopAnimation {
|
|
66
99
|
[_displayLink invalidate];
|
|
67
100
|
_displayLink = nil;
|
|
101
|
+
_displayLinkProxy = nil;
|
|
68
102
|
}
|
|
69
103
|
|
|
70
104
|
- (NSUInteger)indexForDistance:(CGFloat)distance {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
105
|
+
NSUInteger left = 0;
|
|
106
|
+
NSUInteger right = _cumulativeDistances.count - 1;
|
|
107
|
+
|
|
108
|
+
while (left < right) {
|
|
109
|
+
NSUInteger mid = (left + right + 1) / 2;
|
|
110
|
+
if (_cumulativeDistances[mid].doubleValue <= distance) {
|
|
111
|
+
left = mid;
|
|
112
|
+
} else {
|
|
113
|
+
right = mid - 1;
|
|
74
114
|
}
|
|
75
115
|
}
|
|
76
|
-
|
|
116
|
+
|
|
117
|
+
return MIN(left, _cumulativeDistances.count - 2);
|
|
77
118
|
}
|
|
78
119
|
|
|
79
120
|
- (void)animationTick:(CADisplayLink *)displayLink {
|
|
@@ -222,9 +263,8 @@
|
|
|
222
263
|
UIColor *startColor = [self colorAtGradientPosition:gradientStart];
|
|
223
264
|
UIColor *endColor = [self colorAtGradientPosition:gradientEnd];
|
|
224
265
|
|
|
225
|
-
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
|
|
226
266
|
NSArray *colors = @[(__bridge id)startColor.CGColor, (__bridge id)endColor.CGColor];
|
|
227
|
-
CGGradientRef gradient = CGGradientCreateWithColors(
|
|
267
|
+
CGGradientRef gradient = CGGradientCreateWithColors(_colorSpace, (__bridge CFArrayRef)colors, NULL);
|
|
228
268
|
|
|
229
269
|
CGContextSaveGState(context);
|
|
230
270
|
CGContextBeginPath(context);
|
|
@@ -237,7 +277,6 @@
|
|
|
237
277
|
|
|
238
278
|
CGContextRestoreGState(context);
|
|
239
279
|
CGGradientRelease(gradient);
|
|
240
|
-
CGColorSpaceRelease(colorSpace);
|
|
241
280
|
}
|
|
242
281
|
return;
|
|
243
282
|
}
|
|
@@ -254,9 +293,8 @@
|
|
|
254
293
|
UIColor *startColor = [self colorAtGradientPosition:gradientStart];
|
|
255
294
|
UIColor *endColor = [self colorAtGradientPosition:gradientEnd];
|
|
256
295
|
|
|
257
|
-
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
|
|
258
296
|
NSArray *colors = @[(__bridge id)startColor.CGColor, (__bridge id)endColor.CGColor];
|
|
259
|
-
CGGradientRef gradient = CGGradientCreateWithColors(
|
|
297
|
+
CGGradientRef gradient = CGGradientCreateWithColors(_colorSpace, (__bridge CFArrayRef)colors, NULL);
|
|
260
298
|
|
|
261
299
|
CGContextSaveGState(context);
|
|
262
300
|
CGContextBeginPath(context);
|
|
@@ -269,7 +307,6 @@
|
|
|
269
307
|
|
|
270
308
|
CGContextRestoreGState(context);
|
|
271
309
|
CGGradientRelease(gradient);
|
|
272
|
-
CGColorSpaceRelease(colorSpace);
|
|
273
310
|
}
|
|
274
311
|
return;
|
|
275
312
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import { createContext, useContext } from 'react';
|
|
3
4
|
import { APIProvider } from '@vis.gl/react-google-maps';
|
|
4
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
export const MapIdContext = /*#__PURE__*/createContext(null);
|
|
7
|
+
export const useMapId = () => useContext(MapIdContext);
|
|
5
8
|
export function MapProvider({
|
|
6
9
|
apiKey = '',
|
|
7
10
|
children
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["APIProvider","jsx","_jsx","MapProvider","apiKey","children"],"sourceRoot":"../../src","sources":["MapProvider.web.tsx"],"mappings":";;AAAA,SAASA,WAAW,QAAQ,2BAA2B;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAGxD,OAAO,
|
|
1
|
+
{"version":3,"names":["createContext","useContext","APIProvider","jsx","_jsx","MapIdContext","useMapId","MapProvider","apiKey","children"],"sourceRoot":"../../src","sources":["MapProvider.web.tsx"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,UAAU,QAAQ,OAAO;AACjD,SAASC,WAAW,QAAQ,2BAA2B;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAGxD,OAAO,MAAMC,YAAY,gBAAGL,aAAa,CAAgB,IAAI,CAAC;AAE9D,OAAO,MAAMM,QAAQ,GAAGA,CAAA,KAAML,UAAU,CAACI,YAAY,CAAC;AAEtD,OAAO,SAASE,WAAWA,CAAC;EAAEC,MAAM,GAAG,EAAE;EAAEC;AAA2B,CAAC,EAAE;EACvE,oBAAOL,IAAA,CAACF,WAAW;IAACM,MAAM,EAAEA,MAAO;IAAAC,QAAA,EAAEA;EAAQ,CAAc,CAAC;AAC9D","ignoreList":[]}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { Children, forwardRef, isValidElement, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
3
|
+
import { Children, forwardRef, isValidElement, useEffect, useId, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
4
4
|
import { View } from 'react-native';
|
|
5
5
|
import { Map, useMap } from '@vis.gl/react-google-maps';
|
|
6
6
|
import { Marker } from "./components/Marker.web.js";
|
|
7
7
|
import { Polyline } from "./components/Polyline.web.js";
|
|
8
|
+
import { MapIdContext } from "./MapProvider.web.js";
|
|
8
9
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
10
|
const MAP_COMPONENT_TYPES = new Set([Marker, Polyline]);
|
|
10
11
|
const isMapComponent = child => MAP_COMPONENT_TYPES.has(child.type);
|
|
@@ -71,7 +72,7 @@ function UserLocationMarker({
|
|
|
71
72
|
}
|
|
72
73
|
export const MapView = /*#__PURE__*/forwardRef(function MapView(props, ref) {
|
|
73
74
|
const {
|
|
74
|
-
mapId =
|
|
75
|
+
mapId = google.maps.Map.DEMO_MAP_ID,
|
|
75
76
|
initialCoordinate,
|
|
76
77
|
initialZoom = 10,
|
|
77
78
|
minZoom,
|
|
@@ -87,7 +88,8 @@ export const MapView = /*#__PURE__*/forwardRef(function MapView(props, ref) {
|
|
|
87
88
|
children,
|
|
88
89
|
style
|
|
89
90
|
} = props;
|
|
90
|
-
const
|
|
91
|
+
const id = useId();
|
|
92
|
+
const map = useMap(id);
|
|
91
93
|
const readyFired = useRef(false);
|
|
92
94
|
useImperativeHandle(ref, () => ({
|
|
93
95
|
moveCamera(coordinate, options) {
|
|
@@ -185,21 +187,30 @@ export const MapView = /*#__PURE__*/forwardRef(function MapView(props, ref) {
|
|
|
185
187
|
google.maps.event.removeListener(idleListener);
|
|
186
188
|
};
|
|
187
189
|
}, [map, onCameraMove, onCameraIdle]);
|
|
188
|
-
const gestureHandling = scrollEnabled === false && zoomEnabled === false ? 'none' : scrollEnabled === false ? '
|
|
190
|
+
const gestureHandling = scrollEnabled === false && zoomEnabled === false ? 'none' : scrollEnabled === false ? 'cooperative' : 'auto';
|
|
189
191
|
const defaultCenter = initialCoordinate ? {
|
|
190
192
|
lat: initialCoordinate.latitude,
|
|
191
193
|
lng: initialCoordinate.longitude
|
|
192
194
|
} : undefined;
|
|
193
|
-
const
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
195
|
+
const {
|
|
196
|
+
mapChildren,
|
|
197
|
+
overlayChildren
|
|
198
|
+
} = useMemo(() => {
|
|
199
|
+
const mapNodes = [];
|
|
200
|
+
const overlayNodes = [];
|
|
201
|
+
Children.forEach(children, child => {
|
|
202
|
+
if (! /*#__PURE__*/isValidElement(child)) return;
|
|
203
|
+
if (isMapComponent(child)) {
|
|
204
|
+
mapNodes.push(child);
|
|
205
|
+
} else {
|
|
206
|
+
overlayNodes.push(child);
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
return {
|
|
210
|
+
mapChildren: mapNodes,
|
|
211
|
+
overlayChildren: overlayNodes
|
|
212
|
+
};
|
|
213
|
+
}, [children]);
|
|
203
214
|
const mapContainerStyle = {
|
|
204
215
|
position: 'absolute',
|
|
205
216
|
top: padding?.top ?? 0,
|
|
@@ -211,25 +222,29 @@ export const MapView = /*#__PURE__*/forwardRef(function MapView(props, ref) {
|
|
|
211
222
|
width: '100%',
|
|
212
223
|
height: '100%'
|
|
213
224
|
};
|
|
214
|
-
return /*#__PURE__*/
|
|
215
|
-
|
|
216
|
-
children:
|
|
217
|
-
style:
|
|
218
|
-
children: /*#__PURE__*/
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
225
|
+
return /*#__PURE__*/_jsx(MapIdContext.Provider, {
|
|
226
|
+
value: id,
|
|
227
|
+
children: /*#__PURE__*/_jsxs(View, {
|
|
228
|
+
style: style,
|
|
229
|
+
children: [/*#__PURE__*/_jsx(View, {
|
|
230
|
+
style: mapContainerStyle,
|
|
231
|
+
children: /*#__PURE__*/_jsxs(Map, {
|
|
232
|
+
id: id,
|
|
233
|
+
mapId: mapId,
|
|
234
|
+
defaultCenter: defaultCenter,
|
|
235
|
+
defaultZoom: initialZoom,
|
|
236
|
+
minZoom: minZoom,
|
|
237
|
+
maxZoom: maxZoom,
|
|
238
|
+
gestureHandling: gestureHandling,
|
|
239
|
+
disableDefaultUI: true,
|
|
240
|
+
tilt: pitchEnabled === false ? 0 : undefined,
|
|
241
|
+
style: mapStyle,
|
|
242
|
+
children: [/*#__PURE__*/_jsx(UserLocationMarker, {
|
|
243
|
+
enabled: userLocationEnabled
|
|
244
|
+
}), mapChildren]
|
|
245
|
+
})
|
|
246
|
+
}), overlayChildren]
|
|
247
|
+
})
|
|
233
248
|
});
|
|
234
249
|
});
|
|
235
250
|
//# sourceMappingURL=MapView.web.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Children","forwardRef","isValidElement","useEffect","useImperativeHandle","useRef","useState","View","Map","useMap","Marker","Polyline","jsx","_jsx","jsxs","_jsxs","MAP_COMPONENT_TYPES","Set","isMapComponent","child","has","type","createSyntheticEvent","nativeEvent","currentTarget","target","bubbles","cancelable","defaultPrevented","eventPhase","isTrusted","preventDefault","stopPropagation","isDefaultPrevented","isPropagationStopped","persist","timeStamp","Date","now","userLocationDotStyle","width","height","backgroundColor","border","borderRadius","boxShadow","UserLocationMarker","enabled","coordinate","setCoordinate","watchId","updateLocation","position","latitude","coords","longitude","navigator","geolocation","getCurrentPosition","watchPosition","clearWatch","anchor","x","y","children","style","MapView","props","ref","mapId","initialCoordinate","initialZoom","minZoom","maxZoom","zoomEnabled","scrollEnabled","pitchEnabled","padding","userLocationEnabled","onCameraMove","onCameraIdle","onReady","map","readyFired","moveCamera","options","zoom","duration","center","lat","lng","currentZoom","getZoom","zoomChanged","undefined","setZoom","panTo","fitCoordinates","coordinates","first","fitPadding","length","bounds","
|
|
1
|
+
{"version":3,"names":["Children","forwardRef","isValidElement","useEffect","useId","useImperativeHandle","useMemo","useRef","useState","View","Map","useMap","Marker","Polyline","MapIdContext","jsx","_jsx","jsxs","_jsxs","MAP_COMPONENT_TYPES","Set","isMapComponent","child","has","type","createSyntheticEvent","nativeEvent","currentTarget","target","bubbles","cancelable","defaultPrevented","eventPhase","isTrusted","preventDefault","stopPropagation","isDefaultPrevented","isPropagationStopped","persist","timeStamp","Date","now","userLocationDotStyle","width","height","backgroundColor","border","borderRadius","boxShadow","UserLocationMarker","enabled","coordinate","setCoordinate","watchId","updateLocation","position","latitude","coords","longitude","navigator","geolocation","getCurrentPosition","watchPosition","clearWatch","anchor","x","y","children","style","MapView","props","ref","mapId","google","maps","DEMO_MAP_ID","initialCoordinate","initialZoom","minZoom","maxZoom","zoomEnabled","scrollEnabled","pitchEnabled","padding","userLocationEnabled","onCameraMove","onCameraIdle","onReady","id","map","readyFired","moveCamera","options","zoom","duration","center","lat","lng","currentZoom","getZoom","zoomChanged","undefined","setZoom","panTo","fitCoordinates","coordinates","first","fitPadding","length","bounds","LatLngBounds","forEach","coord","extend","fitBounds","top","left","bottom","right","current","createPayload","gesture","getCenter","isDragging","wasGesture","dragStartListener","addListener","dragEndListener","centerListener","idleListener","event","removeListener","gestureHandling","defaultCenter","mapChildren","overlayChildren","mapNodes","overlayNodes","push","mapContainerStyle","mapStyle","Provider","value","defaultZoom","disableDefaultUI","tilt"],"sourceRoot":"../../src","sources":["MapView.web.tsx"],"mappings":";;AAAA,SACEA,QAAQ,EACRC,UAAU,EACVC,cAAc,EACdC,SAAS,EACTC,KAAK,EACLC,mBAAmB,EACnBC,OAAO,EACPC,MAAM,EACNC,QAAQ,QAIH,OAAO;AAEd,SAASC,IAAI,QAAQ,cAAc;AACnC,SAASC,GAAG,EAAEC,MAAM,QAAQ,2BAA2B;AACvD,SAASC,MAAM,QAAQ,4BAAyB;AAChD,SAASC,QAAQ,QAAQ,8BAA2B;AACpD,SAASC,YAAY,QAAQ,sBAAmB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAWjD,MAAMC,mBAAmB,GAAG,IAAIC,GAAG,CAAC,CAACR,MAAM,EAAEC,QAAQ,CAAC,CAAC;AAEvD,MAAMQ,cAAc,GAAIC,KAAmB,IACzCH,mBAAmB,CAACI,GAAG,CAACD,KAAK,CAACE,IAAuC,CAAC;AAExE,MAAMC,oBAAoB,GAAQC,WAAc,KAC7C;EACCA,WAAW;EACXC,aAAa,EAAE,IAAI;EACnBC,MAAM,EAAE,IAAI;EACZC,OAAO,EAAE,KAAK;EACdC,UAAU,EAAE,KAAK;EACjBC,gBAAgB,EAAE,KAAK;EACvBC,UAAU,EAAE,CAAC;EACbC,SAAS,EAAE,IAAI;EACfC,cAAc,EAAEA,CAAA,KAAM,CAAC,CAAC;EACxBC,eAAe,EAAEA,CAAA,KAAM,CAAC,CAAC;EACzBC,kBAAkB,EAAEA,CAAA,KAAM,KAAK;EAC/BC,oBAAoB,EA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|
|
|
2
2
|
|
|
3
3
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
4
4
|
import { useMap } from '@vis.gl/react-google-maps';
|
|
5
|
+
import { useMapId } from "../MapProvider.web.js";
|
|
5
6
|
const ANIMATION_DURATION = 1500;
|
|
6
7
|
function interpolateColor(color1, color2, t) {
|
|
7
8
|
const hex = c => parseInt(c, 16);
|
|
@@ -33,7 +34,8 @@ export function Polyline({
|
|
|
33
34
|
zIndex
|
|
34
35
|
}) {
|
|
35
36
|
const resolvedZIndex = zIndex ?? (animated ? 1 : 0);
|
|
36
|
-
const
|
|
37
|
+
const mapId = useMapId();
|
|
38
|
+
const map = useMap(mapId);
|
|
37
39
|
const polylinesRef = useRef([]);
|
|
38
40
|
const animationRef = useRef(0);
|
|
39
41
|
const colors = useMemo(() => strokeColors && strokeColors.length > 0 ? strokeColors : ['#000000'], [strokeColors]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useCallback","useEffect","useMemo","useRef","useState","useMap","ANIMATION_DURATION","interpolateColor","color1","color2","t","hex","c","parseInt","r1","slice","g1","b1","r2","g2","b2","r","Math","round","g","b","toString","padStart","getGradientColor","colors","position","length","scaledPos","index","floor","Polyline","coordinates","strokeColors","strokeWidth","animated","zIndex","resolvedZIndex","map","polylinesRef","animationRef","hasGradient","propsRef","mapReady","setMapReady","current","updatePath","path","currentMap","currentColors","currentStrokeWidth","currentHasGradient","currentZIndex","neededSegments","existing","i","segmentPath","color","segment","setPath","setOptions","strokeColor","push","google","maps","strokeWeight","strokeOpacity","setMap","polylines","cancelAnimationFrame","forEach","p","fullPath","lat","latitude","lng","longitude","totalPoints","cycleDuration","animate","time","progress","startIdx","endIdx","partialPath","startFloor","endFloor","frac","from","to","min","requestAnimationFrame"],"sourceRoot":"../../../src","sources":["components/Polyline.web.tsx"],"mappings":";;AAAA,SAASA,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AACzE,SAASC,MAAM,QAAQ,2BAA2B;
|
|
1
|
+
{"version":3,"names":["useCallback","useEffect","useMemo","useRef","useState","useMap","useMapId","ANIMATION_DURATION","interpolateColor","color1","color2","t","hex","c","parseInt","r1","slice","g1","b1","r2","g2","b2","r","Math","round","g","b","toString","padStart","getGradientColor","colors","position","length","scaledPos","index","floor","Polyline","coordinates","strokeColors","strokeWidth","animated","zIndex","resolvedZIndex","mapId","map","polylinesRef","animationRef","hasGradient","propsRef","mapReady","setMapReady","current","updatePath","path","currentMap","currentColors","currentStrokeWidth","currentHasGradient","currentZIndex","neededSegments","existing","i","segmentPath","color","segment","setPath","setOptions","strokeColor","push","google","maps","strokeWeight","strokeOpacity","setMap","polylines","cancelAnimationFrame","forEach","p","fullPath","lat","latitude","lng","longitude","totalPoints","cycleDuration","animate","time","progress","startIdx","endIdx","partialPath","startFloor","endFloor","frac","from","to","min","requestAnimationFrame"],"sourceRoot":"../../../src","sources":["components/Polyline.web.tsx"],"mappings":";;AAAA,SAASA,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AACzE,SAASC,MAAM,QAAQ,2BAA2B;AAClD,SAASC,QAAQ,QAAQ,uBAAoB;AAG7C,MAAMC,kBAAkB,GAAG,IAAI;AAE/B,SAASC,gBAAgBA,CAACC,MAAc,EAAEC,MAAc,EAAEC,CAAS,EAAU;EAC3E,MAAMC,GAAG,GAAIC,CAAS,IAAKC,QAAQ,CAACD,CAAC,EAAE,EAAE,CAAC;EAC1C,MAAME,EAAE,GAAGH,GAAG,CAACH,MAAM,CAACO,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;EAClC,MAAMC,EAAE,GAAGL,GAAG,CAACH,MAAM,CAACO,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;EAClC,MAAME,EAAE,GAAGN,GAAG,CAACH,MAAM,CAACO,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;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AAC,IAAItC,IAAI,CAACyE,GAAG,CAACJ,QAAQ,EAAET,WAAW,GAAG,CAAC,CAAC,EACxCtB,CAAC,EAAE,EACH;QACA6B,WAAW,CAACtB,IAAI,CAACU,QAAQ,CAACjB,CAAC,CAAE,CAAC;MAChC;;MAEA;MACA,IAAI+B,QAAQ,GAAGT,WAAW,GAAG,CAAC,EAAE;QAC9B,MAAMU,IAAI,GAAGJ,MAAM,GAAGG,QAAQ;QAC9B,MAAME,IAAI,GAAGhB,QAAQ,CAACc,QAAQ,CAAE;QAChC,MAAMG,EAAE,GAAGjB,QAAQ,CAACc,QAAQ,GAAG,CAAC,CAAE;QAClC,IAAIC,IAAI,GAAG,CAAC,EAAE;UACZH,WAAW,CAACtB,IAAI,CAAC;YACfW,GAAG,EAAEe,IAAI,CAACf,GAAG,GAAG,CAACgB,EAAE,CAAChB,GAAG,GAAGe,IAAI,CAACf,GAAG,IAAIc,IAAI;YAC1CZ,GAAG,EAAEa,IAAI,CAACb,GAAG,GAAG,CAACc,EAAE,CAACd,GAAG,GAAGa,IAAI,CAACb,GAAG,IAAIY;UACxC,CAAC,CAAC;QACJ;MACF;MAEAzC,UAAU,CAACsC,WAAW,CAAC;MACvB5C,YAAY,CAACK,OAAO,GAAG8C,qBAAqB,CAACZ,OAAO,CAAC;IACvD,CAAC;IAEDvC,YAAY,CAACK,OAAO,GAAG8C,qBAAqB,CAACZ,OAAO,CAAC;IAErD,OAAO,MAAMV,oBAAoB,CAAC7B,YAAY,CAACK,OAAO,CAAC;EACzD,CAAC,EAAE,CAACd,WAAW,EAAEG,QAAQ,EAAEO,WAAW,EAAEK,UAAU,EAAEH,QAAQ,CAAC,CAAC;EAE9D,OAAO,IAAI;AACb","ignoreList":[]}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { MapProviderProps } from './MapProvider.types';
|
|
2
|
+
export declare const MapIdContext: import("react").Context<string | null>;
|
|
3
|
+
export declare const useMapId: () => string | null;
|
|
2
4
|
export declare function MapProvider({ apiKey, children }: MapProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
3
5
|
//# sourceMappingURL=MapProvider.web.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapProvider.web.d.ts","sourceRoot":"","sources":["../../../src/MapProvider.web.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MapProvider.web.d.ts","sourceRoot":"","sources":["../../../src/MapProvider.web.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,eAAO,MAAM,YAAY,wCAAqC,CAAC;AAE/D,eAAO,MAAM,QAAQ,qBAAiC,CAAC;AAEvD,wBAAgB,WAAW,CAAC,EAAE,MAAW,EAAE,QAAQ,EAAE,EAAE,gBAAgB,2CAEtE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapView.web.d.ts","sourceRoot":"","sources":["../../../src/MapView.web.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MapView.web.d.ts","sourceRoot":"","sources":["../../../src/MapView.web.tsx"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EAIX,MAAM,iBAAiB,CAAC;AAyEzB,eAAO,MAAM,OAAO,qGAiMlB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Polyline.web.d.ts","sourceRoot":"","sources":["../../../../src/components/Polyline.web.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Polyline.web.d.ts","sourceRoot":"","sources":["../../../../src/components/Polyline.web.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAkChD,wBAAgB,QAAQ,CAAC,EACvB,WAAW,EACX,YAAY,EACZ,WAAe,EACf,QAAQ,EACR,MAAM,GACP,EAAE,aAAa,QAuKf"}
|
package/package.json
CHANGED
package/src/MapProvider.web.tsx
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
1
2
|
import { APIProvider } from '@vis.gl/react-google-maps';
|
|
2
3
|
import type { MapProviderProps } from './MapProvider.types';
|
|
3
4
|
|
|
5
|
+
export const MapIdContext = createContext<string | null>(null);
|
|
6
|
+
|
|
7
|
+
export const useMapId = () => useContext(MapIdContext);
|
|
8
|
+
|
|
4
9
|
export function MapProvider({ apiKey = '', children }: MapProviderProps) {
|
|
5
10
|
return <APIProvider apiKey={apiKey}>{children}</APIProvider>;
|
|
6
11
|
}
|
package/src/MapView.web.tsx
CHANGED
|
@@ -3,7 +3,9 @@ import {
|
|
|
3
3
|
forwardRef,
|
|
4
4
|
isValidElement,
|
|
5
5
|
useEffect,
|
|
6
|
+
useId,
|
|
6
7
|
useImperativeHandle,
|
|
8
|
+
useMemo,
|
|
7
9
|
useRef,
|
|
8
10
|
useState,
|
|
9
11
|
type CSSProperties,
|
|
@@ -15,6 +17,7 @@ import { View } from 'react-native';
|
|
|
15
17
|
import { Map, useMap } from '@vis.gl/react-google-maps';
|
|
16
18
|
import { Marker } from './components/Marker.web';
|
|
17
19
|
import { Polyline } from './components/Polyline.web';
|
|
20
|
+
import { MapIdContext } from './MapProvider.web';
|
|
18
21
|
|
|
19
22
|
import type {
|
|
20
23
|
MapViewProps,
|
|
@@ -100,7 +103,7 @@ export const MapView = forwardRef<MapViewRef, MapViewProps>(function MapView(
|
|
|
100
103
|
ref
|
|
101
104
|
) {
|
|
102
105
|
const {
|
|
103
|
-
mapId =
|
|
106
|
+
mapId = google.maps.Map.DEMO_MAP_ID,
|
|
104
107
|
initialCoordinate,
|
|
105
108
|
initialZoom = 10,
|
|
106
109
|
minZoom,
|
|
@@ -117,7 +120,8 @@ export const MapView = forwardRef<MapViewRef, MapViewProps>(function MapView(
|
|
|
117
120
|
style,
|
|
118
121
|
} = props;
|
|
119
122
|
|
|
120
|
-
const
|
|
123
|
+
const id = useId();
|
|
124
|
+
const map = useMap(id);
|
|
121
125
|
const readyFired = useRef(false);
|
|
122
126
|
|
|
123
127
|
useImperativeHandle(
|
|
@@ -227,24 +231,28 @@ export const MapView = forwardRef<MapViewRef, MapViewProps>(function MapView(
|
|
|
227
231
|
scrollEnabled === false && zoomEnabled === false
|
|
228
232
|
? 'none'
|
|
229
233
|
: scrollEnabled === false
|
|
230
|
-
? '
|
|
234
|
+
? 'cooperative'
|
|
231
235
|
: 'auto';
|
|
232
236
|
|
|
233
237
|
const defaultCenter = initialCoordinate
|
|
234
238
|
? { lat: initialCoordinate.latitude, lng: initialCoordinate.longitude }
|
|
235
239
|
: undefined;
|
|
236
240
|
|
|
237
|
-
const mapChildren
|
|
238
|
-
|
|
241
|
+
const { mapChildren, overlayChildren } = useMemo(() => {
|
|
242
|
+
const mapNodes: ReactNode[] = [];
|
|
243
|
+
const overlayNodes: ReactNode[] = [];
|
|
239
244
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
245
|
+
Children.forEach(children, (child) => {
|
|
246
|
+
if (!isValidElement(child)) return;
|
|
247
|
+
if (isMapComponent(child)) {
|
|
248
|
+
mapNodes.push(child);
|
|
249
|
+
} else {
|
|
250
|
+
overlayNodes.push(child);
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
return { mapChildren: mapNodes, overlayChildren: overlayNodes };
|
|
255
|
+
}, [children]);
|
|
248
256
|
|
|
249
257
|
const mapContainerStyle: ViewStyle = {
|
|
250
258
|
position: 'absolute',
|
|
@@ -260,24 +268,27 @@ export const MapView = forwardRef<MapViewRef, MapViewProps>(function MapView(
|
|
|
260
268
|
};
|
|
261
269
|
|
|
262
270
|
return (
|
|
263
|
-
<
|
|
264
|
-
<View style={
|
|
265
|
-
<
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
271
|
+
<MapIdContext.Provider value={id}>
|
|
272
|
+
<View style={style}>
|
|
273
|
+
<View style={mapContainerStyle}>
|
|
274
|
+
<Map
|
|
275
|
+
id={id}
|
|
276
|
+
mapId={mapId}
|
|
277
|
+
defaultCenter={defaultCenter}
|
|
278
|
+
defaultZoom={initialZoom}
|
|
279
|
+
minZoom={minZoom}
|
|
280
|
+
maxZoom={maxZoom}
|
|
281
|
+
gestureHandling={gestureHandling}
|
|
282
|
+
disableDefaultUI
|
|
283
|
+
tilt={pitchEnabled === false ? 0 : undefined}
|
|
284
|
+
style={mapStyle}
|
|
285
|
+
>
|
|
286
|
+
<UserLocationMarker enabled={userLocationEnabled} />
|
|
287
|
+
{mapChildren}
|
|
288
|
+
</Map>
|
|
289
|
+
</View>
|
|
290
|
+
{overlayChildren}
|
|
279
291
|
</View>
|
|
280
|
-
|
|
281
|
-
</View>
|
|
292
|
+
</MapIdContext.Provider>
|
|
282
293
|
);
|
|
283
294
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
2
|
import { useMap } from '@vis.gl/react-google-maps';
|
|
3
|
+
import { useMapId } from '../MapProvider.web';
|
|
3
4
|
import type { PolylineProps } from './Polyline';
|
|
4
5
|
|
|
5
6
|
const ANIMATION_DURATION = 1500;
|
|
@@ -42,7 +43,8 @@ export function Polyline({
|
|
|
42
43
|
zIndex,
|
|
43
44
|
}: PolylineProps) {
|
|
44
45
|
const resolvedZIndex = zIndex ?? (animated ? 1 : 0);
|
|
45
|
-
const
|
|
46
|
+
const mapId = useMapId();
|
|
47
|
+
const map = useMap(mapId);
|
|
46
48
|
const polylinesRef = useRef<google.maps.Polyline[]>([]);
|
|
47
49
|
const animationRef = useRef<number>(0);
|
|
48
50
|
|