@lugg/maps 0.2.0-alpha.12 → 0.2.0-alpha.14
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 +17 -38
- package/lib/module/MapView.web.js.map +1 -1
- package/lib/module/components/Polyline.web.js +1 -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/package.json +1 -1
- package/src/MapProvider.web.tsx +5 -0
- package/src/MapView.web.tsx +13 -44
- package/src/components/Polyline.web.tsx +1 -1
- package/lib/module/MapIdContext.web.js +0 -6
- package/lib/module/MapIdContext.web.js.map +0 -1
- package/lib/typescript/src/MapIdContext.web.d.ts +0 -3
- package/lib/typescript/src/MapIdContext.web.d.ts.map +0 -1
- package/src/MapIdContext.web.ts +0 -5
|
@@ -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,14 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { forwardRef, useEffect, useId, useImperativeHandle, 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
|
-
import {
|
|
8
|
-
import { MapIdContext } from "./MapIdContext.web.js";
|
|
7
|
+
import { MapIdContext } from "./MapProvider.web.js";
|
|
9
8
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
-
const MAP_COMPONENT_TYPES = new Set([Marker, Polyline]);
|
|
11
|
-
const isMapComponent = child => MAP_COMPONENT_TYPES.has(child.type);
|
|
12
9
|
const createSyntheticEvent = nativeEvent => ({
|
|
13
10
|
nativeEvent,
|
|
14
11
|
currentTarget: null,
|
|
@@ -72,7 +69,7 @@ function UserLocationMarker({
|
|
|
72
69
|
}
|
|
73
70
|
export const MapView = /*#__PURE__*/forwardRef(function MapView(props, ref) {
|
|
74
71
|
const {
|
|
75
|
-
mapId =
|
|
72
|
+
mapId = google.maps.Map.DEMO_MAP_ID,
|
|
76
73
|
initialCoordinate,
|
|
77
74
|
initialZoom = 10,
|
|
78
75
|
minZoom,
|
|
@@ -187,37 +184,22 @@ export const MapView = /*#__PURE__*/forwardRef(function MapView(props, ref) {
|
|
|
187
184
|
google.maps.event.removeListener(idleListener);
|
|
188
185
|
};
|
|
189
186
|
}, [map, onCameraMove, onCameraIdle]);
|
|
190
|
-
const gestureHandling = scrollEnabled === false && zoomEnabled === false ? 'none' : scrollEnabled === false ? '
|
|
187
|
+
const gestureHandling = scrollEnabled === false && zoomEnabled === false ? 'none' : scrollEnabled === false ? 'cooperative' : 'auto';
|
|
191
188
|
const defaultCenter = initialCoordinate ? {
|
|
192
189
|
lat: initialCoordinate.latitude,
|
|
193
190
|
lng: initialCoordinate.longitude
|
|
194
191
|
} : undefined;
|
|
195
|
-
const mapChildren = [];
|
|
196
|
-
const overlayChildren = [];
|
|
197
|
-
Children.forEach(children, child => {
|
|
198
|
-
if (! /*#__PURE__*/isValidElement(child)) return;
|
|
199
|
-
if (isMapComponent(child)) {
|
|
200
|
-
mapChildren.push(child);
|
|
201
|
-
} else {
|
|
202
|
-
overlayChildren.push(child);
|
|
203
|
-
}
|
|
204
|
-
});
|
|
205
|
-
const mapContainerStyle = {
|
|
206
|
-
position: 'absolute',
|
|
207
|
-
top: padding?.top ?? 0,
|
|
208
|
-
left: padding?.left ?? 0,
|
|
209
|
-
right: padding?.right ?? 0,
|
|
210
|
-
bottom: padding?.bottom ?? 0
|
|
211
|
-
};
|
|
212
192
|
const mapStyle = {
|
|
213
|
-
|
|
214
|
-
|
|
193
|
+
paddingTop: padding?.top ?? 0,
|
|
194
|
+
paddingLeft: padding?.left ?? 0,
|
|
195
|
+
paddingRight: padding?.right ?? 0,
|
|
196
|
+
paddingBottom: padding?.bottom ?? 0
|
|
215
197
|
};
|
|
216
|
-
return /*#__PURE__*/
|
|
217
|
-
|
|
218
|
-
children:
|
|
219
|
-
style:
|
|
220
|
-
children: /*#__PURE__*/
|
|
198
|
+
return /*#__PURE__*/_jsx(MapIdContext.Provider, {
|
|
199
|
+
value: id,
|
|
200
|
+
children: /*#__PURE__*/_jsx(View, {
|
|
201
|
+
style: style,
|
|
202
|
+
children: /*#__PURE__*/_jsxs(Map, {
|
|
221
203
|
id: id,
|
|
222
204
|
mapId: mapId,
|
|
223
205
|
defaultCenter: defaultCenter,
|
|
@@ -228,14 +210,11 @@ export const MapView = /*#__PURE__*/forwardRef(function MapView(props, ref) {
|
|
|
228
210
|
disableDefaultUI: true,
|
|
229
211
|
tilt: pitchEnabled === false ? 0 : undefined,
|
|
230
212
|
style: mapStyle,
|
|
231
|
-
children: /*#__PURE__*/
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
enabled: userLocationEnabled
|
|
235
|
-
}), mapChildren]
|
|
236
|
-
})
|
|
213
|
+
children: [/*#__PURE__*/_jsx(UserLocationMarker, {
|
|
214
|
+
enabled: userLocationEnabled
|
|
215
|
+
}), children]
|
|
237
216
|
})
|
|
238
|
-
})
|
|
217
|
+
})
|
|
239
218
|
});
|
|
240
219
|
});
|
|
241
220
|
//# sourceMappingURL=MapView.web.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["forwardRef","useEffect","useId","useImperativeHandle","useRef","useState","View","Map","useMap","Marker","MapIdContext","jsx","_jsx","jsxs","_jsxs","createSyntheticEvent","nativeEvent","currentTarget","target","bubbles","cancelable","defaultPrevented","eventPhase","isTrusted","preventDefault","stopPropagation","isDefaultPrevented","isPropagationStopped","persist","timeStamp","Date","now","type","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","mapStyle","paddingTop","paddingLeft","paddingRight","paddingBottom","Provider","value","defaultZoom","disableDefaultUI","tilt"],"sourceRoot":"../../src","sources":["MapView.web.tsx"],"mappings":";;AAAA,SACEA,UAAU,EACVC,SAAS,EACTC,KAAK,EACLC,mBAAmB,EACnBC,MAAM,EACNC,QAAQ,QAEH,OAAO;AAEd,SAASC,IAAI,QAAQ,cAAc;AACnC,SAASC,GAAG,EAAEC,MAAM,QAAQ,2BAA2B;AACvD,SAASC,MAAM,QAAQ,4BAAyB;AAChD,SAASC,YAAY,QAAQ,sBAAmB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAWjD,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,EAAEA,CAAA,KAAM,KAAK;EACjCC,OAAO,EAAEA,CAAA,KAAM,CAAC,CAAC;EACjBC,SAAS,EAAEC,IAAI,CAACC,GAAG,CAAC,CAAC;EACrBC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OAAQ;QACjBqD,eAAe,EAAEA,eAAgB;QACjCU,gBAAgB;QAChBC,IAAI,EAAE7D,YAAY,KAAK,KAAK,GAAG,CAAC,GAAGmB,SAAU;QAC7CjC,KAAK,EAAEkE,QAAS;QAAAnE,QAAA,gBAEhB9C,IAAA,CAAC4B,kBAAkB;UAACC,OAAO,EAAEkC;QAAoB,CAAE,CAAC,EACnDjB,QAAQ;MAAA,CACN;IAAC,CACF;EAAC,CACc,CAAC;AAE5B,CAAC,CAAC","ignoreList":[]}
|
|
@@ -2,7 +2,7 @@
|
|
|
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 "../
|
|
5
|
+
import { useMapId } from "../MapProvider.web.js";
|
|
6
6
|
const ANIMATION_DURATION = 1500;
|
|
7
7
|
function interpolateColor(color1, color2, t) {
|
|
8
8
|
const hex = c => parseInt(c, 16);
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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;E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|
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":"AAeA,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EAIX,MAAM,iBAAiB,CAAC;AAoEzB,eAAO,MAAM,OAAO,qGAwKlB,CAAC"}
|
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
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
|
-
Children,
|
|
3
2
|
forwardRef,
|
|
4
|
-
isValidElement,
|
|
5
3
|
useEffect,
|
|
6
4
|
useId,
|
|
7
5
|
useImperativeHandle,
|
|
8
6
|
useRef,
|
|
9
7
|
useState,
|
|
10
8
|
type CSSProperties,
|
|
11
|
-
type ReactElement,
|
|
12
|
-
type ReactNode,
|
|
13
9
|
} from 'react';
|
|
14
|
-
import type { NativeSyntheticEvent
|
|
10
|
+
import type { NativeSyntheticEvent } from 'react-native';
|
|
15
11
|
import { View } from 'react-native';
|
|
16
12
|
import { Map, useMap } from '@vis.gl/react-google-maps';
|
|
17
13
|
import { Marker } from './components/Marker.web';
|
|
18
|
-
import {
|
|
19
|
-
import { MapIdContext } from './MapIdContext.web';
|
|
14
|
+
import { MapIdContext } from './MapProvider.web';
|
|
20
15
|
|
|
21
16
|
import type {
|
|
22
17
|
MapViewProps,
|
|
@@ -27,11 +22,6 @@ import type {
|
|
|
27
22
|
} from './MapView.types';
|
|
28
23
|
import type { Coordinate } from './types';
|
|
29
24
|
|
|
30
|
-
const MAP_COMPONENT_TYPES = new Set([Marker, Polyline]);
|
|
31
|
-
|
|
32
|
-
const isMapComponent = (child: ReactElement): boolean =>
|
|
33
|
-
MAP_COMPONENT_TYPES.has(child.type as typeof Marker | typeof Polyline);
|
|
34
|
-
|
|
35
25
|
const createSyntheticEvent = <T,>(nativeEvent: T): NativeSyntheticEvent<T> =>
|
|
36
26
|
({
|
|
37
27
|
nativeEvent,
|
|
@@ -102,7 +92,7 @@ export const MapView = forwardRef<MapViewRef, MapViewProps>(function MapView(
|
|
|
102
92
|
ref
|
|
103
93
|
) {
|
|
104
94
|
const {
|
|
105
|
-
mapId =
|
|
95
|
+
mapId = google.maps.Map.DEMO_MAP_ID,
|
|
106
96
|
initialCoordinate,
|
|
107
97
|
initialZoom = 10,
|
|
108
98
|
minZoom,
|
|
@@ -230,41 +220,23 @@ export const MapView = forwardRef<MapViewRef, MapViewProps>(function MapView(
|
|
|
230
220
|
scrollEnabled === false && zoomEnabled === false
|
|
231
221
|
? 'none'
|
|
232
222
|
: scrollEnabled === false
|
|
233
|
-
? '
|
|
223
|
+
? 'cooperative'
|
|
234
224
|
: 'auto';
|
|
235
225
|
|
|
236
226
|
const defaultCenter = initialCoordinate
|
|
237
227
|
? { lat: initialCoordinate.latitude, lng: initialCoordinate.longitude }
|
|
238
228
|
: undefined;
|
|
239
229
|
|
|
240
|
-
const mapChildren: ReactNode[] = [];
|
|
241
|
-
const overlayChildren: ReactNode[] = [];
|
|
242
|
-
|
|
243
|
-
Children.forEach(children, (child) => {
|
|
244
|
-
if (!isValidElement(child)) return;
|
|
245
|
-
if (isMapComponent(child)) {
|
|
246
|
-
mapChildren.push(child);
|
|
247
|
-
} else {
|
|
248
|
-
overlayChildren.push(child);
|
|
249
|
-
}
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
const mapContainerStyle: ViewStyle = {
|
|
253
|
-
position: 'absolute',
|
|
254
|
-
top: padding?.top ?? 0,
|
|
255
|
-
left: padding?.left ?? 0,
|
|
256
|
-
right: padding?.right ?? 0,
|
|
257
|
-
bottom: padding?.bottom ?? 0,
|
|
258
|
-
};
|
|
259
|
-
|
|
260
230
|
const mapStyle: CSSProperties = {
|
|
261
|
-
|
|
262
|
-
|
|
231
|
+
paddingTop: padding?.top ?? 0,
|
|
232
|
+
paddingLeft: padding?.left ?? 0,
|
|
233
|
+
paddingRight: padding?.right ?? 0,
|
|
234
|
+
paddingBottom: padding?.bottom ?? 0,
|
|
263
235
|
};
|
|
264
236
|
|
|
265
237
|
return (
|
|
266
|
-
<
|
|
267
|
-
<View style={
|
|
238
|
+
<MapIdContext.Provider value={id}>
|
|
239
|
+
<View style={style}>
|
|
268
240
|
<Map
|
|
269
241
|
id={id}
|
|
270
242
|
mapId={mapId}
|
|
@@ -277,13 +249,10 @@ export const MapView = forwardRef<MapViewRef, MapViewProps>(function MapView(
|
|
|
277
249
|
tilt={pitchEnabled === false ? 0 : undefined}
|
|
278
250
|
style={mapStyle}
|
|
279
251
|
>
|
|
280
|
-
<
|
|
281
|
-
|
|
282
|
-
{mapChildren}
|
|
283
|
-
</MapIdContext.Provider>
|
|
252
|
+
<UserLocationMarker enabled={userLocationEnabled} />
|
|
253
|
+
{children}
|
|
284
254
|
</Map>
|
|
285
255
|
</View>
|
|
286
|
-
|
|
287
|
-
</View>
|
|
256
|
+
</MapIdContext.Provider>
|
|
288
257
|
);
|
|
289
258
|
});
|
|
@@ -1,6 +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 '../
|
|
3
|
+
import { useMapId } from '../MapProvider.web';
|
|
4
4
|
import type { PolylineProps } from './Polyline';
|
|
5
5
|
|
|
6
6
|
const ANIMATION_DURATION = 1500;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["createContext","useContext","MapIdContext","useMapId"],"sourceRoot":"../../src","sources":["MapIdContext.web.ts"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,UAAU,QAAQ,OAAO;AAEjD,OAAO,MAAMC,YAAY,gBAAGF,aAAa,CAAgB,IAAI,CAAC;AAE9D,OAAO,MAAMG,QAAQ,GAAGA,CAAA,KAAMF,UAAU,CAACC,YAAY,CAAC","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MapIdContext.web.d.ts","sourceRoot":"","sources":["../../../src/MapIdContext.web.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,wCAAqC,CAAC;AAE/D,eAAO,MAAM,QAAQ,qBAAiC,CAAC"}
|