@lugg/maps 0.2.0-alpha.1 → 0.2.0-alpha.11

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.
Files changed (89) hide show
  1. package/README.md +17 -4
  2. package/android/src/main/java/com/luggmaps/LuggGoogleMapView.kt +30 -8
  3. package/android/src/main/java/com/luggmaps/LuggGoogleMapViewManager.kt +10 -2
  4. package/android/src/main/java/com/luggmaps/LuggMarkerView.kt +7 -1
  5. package/android/src/main/java/com/luggmaps/LuggMarkerViewManager.kt +6 -0
  6. package/android/src/main/java/com/luggmaps/LuggPolylineView.kt +7 -0
  7. package/android/src/main/java/com/luggmaps/LuggPolylineViewManager.kt +6 -0
  8. package/android/src/main/java/com/luggmaps/core/PolylineAnimator.kt +89 -43
  9. package/ios/LuggAppleMapView.mm +45 -5
  10. package/ios/LuggGoogleMapView.mm +18 -6
  11. package/ios/LuggMarkerView.h +2 -0
  12. package/ios/LuggMarkerView.mm +13 -0
  13. package/ios/LuggPolylineView.h +1 -0
  14. package/ios/LuggPolylineView.mm +6 -1
  15. package/ios/core/GMSPolylineAnimator.m +85 -36
  16. package/ios/core/MKPolylineAnimator.m +63 -32
  17. package/lib/module/MapProvider.js +13 -0
  18. package/lib/module/MapProvider.js.map +1 -0
  19. package/lib/module/MapProvider.types.js +4 -0
  20. package/lib/module/MapProvider.types.js.map +1 -0
  21. package/lib/module/MapProvider.web.js +14 -0
  22. package/lib/module/MapProvider.web.js.map +1 -0
  23. package/lib/module/MapView.js +8 -2
  24. package/lib/module/MapView.js.map +1 -1
  25. package/lib/module/MapView.web.js +235 -0
  26. package/lib/module/MapView.web.js.map +1 -0
  27. package/lib/module/components/Marker.js +4 -1
  28. package/lib/module/components/Marker.js.map +1 -1
  29. package/lib/module/components/Marker.web.js +25 -0
  30. package/lib/module/components/Marker.web.js.map +1 -0
  31. package/lib/module/components/Polyline.js +5 -2
  32. package/lib/module/components/Polyline.js.map +1 -1
  33. package/lib/module/components/Polyline.web.js +169 -0
  34. package/lib/module/components/Polyline.web.js.map +1 -0
  35. package/lib/module/components/index.js +2 -2
  36. package/lib/module/components/index.js.map +1 -1
  37. package/lib/module/components/index.web.js +5 -0
  38. package/lib/module/components/index.web.js.map +1 -0
  39. package/lib/module/fabric/LuggAppleMapViewNativeComponent.ts +4 -1
  40. package/lib/module/fabric/LuggGoogleMapViewNativeComponent.ts +4 -1
  41. package/lib/module/index.js +3 -2
  42. package/lib/module/index.js.map +1 -1
  43. package/lib/module/index.web.js +6 -0
  44. package/lib/module/index.web.js.map +1 -0
  45. package/lib/typescript/src/MapProvider.d.ts +8 -0
  46. package/lib/typescript/src/MapProvider.d.ts.map +1 -0
  47. package/lib/typescript/src/MapProvider.types.d.ts +16 -0
  48. package/lib/typescript/src/MapProvider.types.d.ts.map +1 -0
  49. package/lib/typescript/src/MapProvider.web.d.ts +3 -0
  50. package/lib/typescript/src/MapProvider.web.d.ts.map +1 -0
  51. package/lib/typescript/src/MapView.d.ts.map +1 -1
  52. package/lib/typescript/src/MapView.types.d.ts +1 -2
  53. package/lib/typescript/src/MapView.types.d.ts.map +1 -1
  54. package/lib/typescript/src/MapView.web.d.ts +3 -0
  55. package/lib/typescript/src/MapView.web.d.ts.map +1 -0
  56. package/lib/typescript/src/components/Marker.d.ts +4 -0
  57. package/lib/typescript/src/components/Marker.d.ts.map +1 -1
  58. package/lib/typescript/src/components/Marker.web.d.ts +3 -0
  59. package/lib/typescript/src/components/Marker.web.d.ts.map +1 -0
  60. package/lib/typescript/src/components/Polyline.d.ts +4 -0
  61. package/lib/typescript/src/components/Polyline.d.ts.map +1 -1
  62. package/lib/typescript/src/components/Polyline.web.d.ts +3 -0
  63. package/lib/typescript/src/components/Polyline.web.d.ts.map +1 -0
  64. package/lib/typescript/src/components/index.web.d.ts +5 -0
  65. package/lib/typescript/src/components/index.web.d.ts.map +1 -0
  66. package/lib/typescript/src/fabric/LuggAppleMapViewNativeComponent.d.ts +1 -1
  67. package/lib/typescript/src/fabric/LuggAppleMapViewNativeComponent.d.ts.map +1 -1
  68. package/lib/typescript/src/fabric/LuggGoogleMapViewNativeComponent.d.ts +1 -1
  69. package/lib/typescript/src/fabric/LuggGoogleMapViewNativeComponent.d.ts.map +1 -1
  70. package/lib/typescript/src/index.d.ts +3 -1
  71. package/lib/typescript/src/index.d.ts.map +1 -1
  72. package/lib/typescript/src/index.web.d.ts +7 -0
  73. package/lib/typescript/src/index.web.d.ts.map +1 -0
  74. package/package.json +15 -2
  75. package/src/MapProvider.tsx +10 -0
  76. package/src/MapProvider.types.ts +16 -0
  77. package/src/MapProvider.web.tsx +6 -0
  78. package/src/MapView.tsx +11 -2
  79. package/src/MapView.types.ts +1 -2
  80. package/src/MapView.web.tsx +283 -0
  81. package/src/components/Marker.tsx +6 -2
  82. package/src/components/Marker.web.tsx +24 -0
  83. package/src/components/Polyline.tsx +6 -1
  84. package/src/components/Polyline.web.tsx +209 -0
  85. package/src/components/index.web.ts +4 -0
  86. package/src/fabric/LuggAppleMapViewNativeComponent.ts +4 -1
  87. package/src/fabric/LuggGoogleMapViewNativeComponent.ts +4 -1
  88. package/src/index.ts +8 -1
  89. package/src/index.web.ts +17 -0
@@ -13,10 +13,12 @@ using namespace facebook::react;
13
13
  @end
14
14
 
15
15
  @implementation LuggMarkerView {
16
+ NSString *_name;
16
17
  CLLocationCoordinate2D _coordinate;
17
18
  NSString *_title;
18
19
  NSString *_markerDescription;
19
20
  CGPoint _anchor;
21
+ NSInteger _zIndex;
20
22
  BOOL _didLayout;
21
23
  UIView *_iconView;
22
24
  }
@@ -34,6 +36,7 @@ using namespace facebook::react;
34
36
 
35
37
  _coordinate = CLLocationCoordinate2DMake(0, 0);
36
38
  _anchor = CGPointMake(0.5, 1.0);
39
+ _zIndex = 0;
37
40
  _didLayout = NO;
38
41
 
39
42
  _iconView = [[UIView alloc] init];
@@ -52,12 +55,14 @@ using namespace facebook::react;
52
55
  const auto &newViewProps =
53
56
  *std::static_pointer_cast<LuggMarkerViewProps const>(props);
54
57
 
58
+ _name = [NSString stringWithUTF8String:newViewProps.name.c_str()];
55
59
  _coordinate = CLLocationCoordinate2DMake(newViewProps.coordinate.latitude,
56
60
  newViewProps.coordinate.longitude);
57
61
  _title = [NSString stringWithUTF8String:newViewProps.title.c_str()];
58
62
  _markerDescription =
59
63
  [NSString stringWithUTF8String:newViewProps.description.c_str()];
60
64
  _anchor = CGPointMake(newViewProps.anchor.x, newViewProps.anchor.y);
65
+ _zIndex = newViewProps.zIndex.value_or(0);
61
66
  }
62
67
 
63
68
  - (void)finalizeUpdates:(RNComponentViewUpdateMask)updateMask {
@@ -109,6 +114,10 @@ using namespace facebook::react;
109
114
  }
110
115
  }
111
116
 
117
+ - (NSString *)name {
118
+ return _name;
119
+ }
120
+
112
121
  - (CLLocationCoordinate2D)coordinate {
113
122
  return _coordinate;
114
123
  }
@@ -125,6 +134,10 @@ using namespace facebook::react;
125
134
  return _anchor;
126
135
  }
127
136
 
137
+ - (NSInteger)zIndex {
138
+ return _zIndex;
139
+ }
140
+
128
141
  - (BOOL)hasCustomView {
129
142
  return _iconView.subviews.count > 0;
130
143
  }
@@ -17,6 +17,7 @@ NS_ASSUME_NONNULL_BEGIN
17
17
  @property(nonatomic, readonly) NSArray<UIColor *> *strokeColors;
18
18
  @property(nonatomic, readonly) BOOL animated;
19
19
  @property(nonatomic, readonly) CGFloat strokeWidth;
20
+ @property(nonatomic, readonly) NSInteger zIndex;
20
21
  @property(nonatomic, weak, nullable) id<LuggPolylineViewDelegate> delegate;
21
22
  @property(nonatomic, strong, nullable) NSObject *polyline;
22
23
  @property(nonatomic, weak, nullable) NSObject *renderer;
@@ -18,6 +18,7 @@ using namespace facebook::react;
18
18
  NSArray<UIColor *> *_strokeColors;
19
19
  BOOL _animated;
20
20
  CGFloat _strokeWidth;
21
+ NSInteger _zIndex;
21
22
  }
22
23
 
23
24
  + (ComponentDescriptorProvider)componentDescriptorProvider {
@@ -71,8 +72,8 @@ using namespace facebook::react;
71
72
  }
72
73
 
73
74
  _animated = newViewProps.animated;
74
-
75
75
  _strokeWidth = newViewProps.strokeWidth > 0 ? newViewProps.strokeWidth : 1.0;
76
+ _zIndex = newViewProps.zIndex.value_or(0);
76
77
  }
77
78
 
78
79
  - (void)finalizeUpdates:(RNComponentViewUpdateMask)updateMask {
@@ -101,6 +102,10 @@ using namespace facebook::react;
101
102
  return _strokeWidth;
102
103
  }
103
104
 
105
+ - (NSInteger)zIndex {
106
+ return _zIndex;
107
+ }
108
+
104
109
  - (void)prepareForRecycle {
105
110
  [super prepareForRecycle];
106
111
  self.polyline = nil;
@@ -4,12 +4,21 @@
4
4
  @implementation GMSPolylineAnimator {
5
5
  CADisplayLink *_displayLink;
6
6
  CGFloat _animationProgress;
7
+ NSArray<NSNumber *> *_cumulativeDistances;
8
+ CGFloat _totalLength;
7
9
  }
8
10
 
9
11
  - (void)dealloc {
10
12
  [self stopAnimation];
11
13
  }
12
14
 
15
+ - (void)setCoordinates:(NSArray<CLLocation *> *)coordinates {
16
+ [super setCoordinates:coordinates];
17
+ if (_animated && _displayLink) {
18
+ [self computeCumulativeDistances];
19
+ }
20
+ }
21
+
13
22
  - (void)setAnimated:(BOOL)animated {
14
23
  if (_animated == animated) {
15
24
  return;
@@ -28,18 +37,35 @@
28
37
  if (_displayLink) {
29
38
  return;
30
39
  }
40
+ [self computeCumulativeDistances];
31
41
  _animationProgress = 0;
32
42
  _displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(animationTick:)];
33
43
  [_displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
34
44
  }
35
45
 
46
+ - (void)computeCumulativeDistances {
47
+ NSMutableArray<NSNumber *> *distances = [NSMutableArray array];
48
+ CGFloat total = 0;
49
+ [distances addObject:@(0)];
50
+
51
+ for (NSUInteger i = 1; i < self.coordinates.count; i++) {
52
+ CLLocation *prev = self.coordinates[i - 1];
53
+ CLLocation *curr = self.coordinates[i];
54
+ total += [prev distanceFromLocation:curr];
55
+ [distances addObject:@(total)];
56
+ }
57
+
58
+ _cumulativeDistances = [distances copy];
59
+ _totalLength = total;
60
+ }
61
+
36
62
  - (void)stopAnimation {
37
63
  [_displayLink invalidate];
38
64
  _displayLink = nil;
39
65
  }
40
66
 
41
67
  - (void)animationTick:(CADisplayLink *)displayLink {
42
- CGFloat speed = displayLink.duration / 1.75;
68
+ CGFloat speed = displayLink.duration / 1.0;
43
69
  _animationProgress += speed;
44
70
 
45
71
  if (_animationProgress >= 2.15) {
@@ -71,63 +97,86 @@
71
97
  }
72
98
  }
73
99
 
100
+ - (NSUInteger)indexForDistance:(CGFloat)distance {
101
+ for (NSUInteger i = 1; i < _cumulativeDistances.count; i++) {
102
+ if (_cumulativeDistances[i].doubleValue >= distance) {
103
+ return i - 1;
104
+ }
105
+ }
106
+ return _cumulativeDistances.count - 2;
107
+ }
108
+
109
+ - (CLLocationCoordinate2D)coordinateAtDistance:(CGFloat)distance {
110
+ if (distance <= 0) {
111
+ return self.coordinates.firstObject.coordinate;
112
+ }
113
+ if (distance >= _totalLength) {
114
+ return self.coordinates.lastObject.coordinate;
115
+ }
116
+
117
+ NSUInteger idx = [self indexForDistance:distance];
118
+ CGFloat segStart = _cumulativeDistances[idx].doubleValue;
119
+ CGFloat segEnd = _cumulativeDistances[idx + 1].doubleValue;
120
+ CGFloat segLength = segEnd - segStart;
121
+
122
+ CGFloat t = (segLength > 0) ? (distance - segStart) / segLength : 0;
123
+ CLLocationCoordinate2D c1 = self.coordinates[idx].coordinate;
124
+ CLLocationCoordinate2D c2 = self.coordinates[idx + 1].coordinate;
125
+
126
+ return CLLocationCoordinate2DMake(c1.latitude + (c2.latitude - c1.latitude) * t,
127
+ c1.longitude + (c2.longitude - c1.longitude) * t);
128
+ }
129
+
74
130
  - (void)updateAnimatedPolyline {
75
- if (!_polyline || self.coordinates.count < 2) {
131
+ if (!_polyline || self.coordinates.count < 2 || _totalLength <= 0) {
76
132
  return;
77
133
  }
78
134
 
79
- NSUInteger segmentCount = self.coordinates.count - 1;
80
135
  CGFloat progress = MIN(_animationProgress, 2.0);
81
- CGFloat headPos, tailPos;
136
+ CGFloat headDist, tailDist;
82
137
 
83
138
  if (progress <= 1.0) {
84
- tailPos = 0;
85
- headPos = progress * segmentCount;
139
+ tailDist = 0;
140
+ headDist = progress * _totalLength;
86
141
  } else {
87
142
  CGFloat shrinkProgress = progress - 1.0;
88
- tailPos = shrinkProgress * segmentCount;
89
- headPos = segmentCount;
143
+ tailDist = shrinkProgress * _totalLength;
144
+ headDist = _totalLength;
90
145
  }
91
146
 
92
- if (headPos <= tailPos) {
147
+ if (headDist <= tailDist) {
93
148
  _polyline.path = [GMSMutablePath path];
94
149
  return;
95
150
  }
96
151
 
97
- NSUInteger startIndex = (NSUInteger)floor(tailPos);
98
- NSUInteger endIndex = (NSUInteger)ceil(headPos);
99
- CGFloat visibleLength = headPos - tailPos;
152
+ CGFloat visibleLength = headDist - tailDist;
153
+ NSUInteger startIndex = [self indexForDistance:tailDist];
154
+ NSUInteger endIndex = [self indexForDistance:headDist];
100
155
 
101
156
  GMSMutablePath *path = [GMSMutablePath path];
102
157
  NSMutableArray<GMSStyleSpan *> *spans = [NSMutableArray array];
103
158
 
104
- for (NSUInteger i = startIndex; i <= endIndex && i < self.coordinates.count; i++) {
105
- CLLocationCoordinate2D coord = self.coordinates[i].coordinate;
106
-
107
- if (i == startIndex && tailPos > (CGFloat)startIndex) {
108
- CGFloat t = tailPos - (CGFloat)startIndex;
109
- CLLocationCoordinate2D nextCoord = self.coordinates[i + 1].coordinate;
110
- coord.latitude = coord.latitude + (nextCoord.latitude - coord.latitude) * t;
111
- coord.longitude = coord.longitude + (nextCoord.longitude - coord.longitude) * t;
112
- }
159
+ CLLocationCoordinate2D startCoord = [self coordinateAtDistance:tailDist];
160
+ [path addCoordinate:startCoord];
113
161
 
114
- if (i == endIndex && headPos < (CGFloat)endIndex && i > 0) {
115
- CGFloat t = headPos - (CGFloat)(endIndex - 1);
116
- CLLocationCoordinate2D prevCoord = self.coordinates[i - 1].coordinate;
117
- coord.latitude = prevCoord.latitude + (coord.latitude - prevCoord.latitude) * t;
118
- coord.longitude = prevCoord.longitude + (coord.longitude - prevCoord.longitude) * t;
119
- }
162
+ for (NSUInteger i = startIndex + 1; i <= endIndex; i++) {
163
+ [path addCoordinate:self.coordinates[i].coordinate];
164
+ }
120
165
 
121
- [path addCoordinate:coord];
166
+ CLLocationCoordinate2D endCoord = [self coordinateAtDistance:headDist];
167
+ CLLocationCoordinate2D lastAdded =
168
+ (endIndex < self.coordinates.count) ? self.coordinates[endIndex].coordinate : endCoord;
169
+ if (endCoord.latitude != lastAdded.latitude || endCoord.longitude != lastAdded.longitude) {
170
+ [path addCoordinate:endCoord];
171
+ }
122
172
 
123
- if (i < endIndex && i < segmentCount) {
124
- CGFloat segStartPos = MAX((CGFloat)i, tailPos);
125
- CGFloat segEndPos = MIN((CGFloat)(i + 1), headPos);
126
- CGFloat gradientMid = ((segStartPos + segEndPos) / 2.0 - tailPos) / visibleLength;
127
- UIColor *color = [self colorAtGradientPosition:gradientMid];
128
- GMSStrokeStyle *style = [GMSStrokeStyle solidColor:color];
129
- [spans addObject:[GMSStyleSpan spanWithStyle:style]];
130
- }
173
+ NSUInteger pathCount = path.count;
174
+ for (NSUInteger i = 0; i < pathCount - 1; i++) {
175
+ CGFloat segMidDist = tailDist + visibleLength * ((CGFloat)i + 0.5) / (CGFloat)(pathCount - 1);
176
+ CGFloat gradientPos = (segMidDist - tailDist) / visibleLength;
177
+ UIColor *color = [self colorAtGradientPosition:gradientPos];
178
+ GMSStrokeStyle *style = [GMSStrokeStyle solidColor:color];
179
+ [spans addObject:[GMSStyleSpan spanWithStyle:style]];
131
180
  }
132
181
 
133
182
  _polyline.path = path;
@@ -4,7 +4,9 @@
4
4
  @implementation MKPolylineAnimator {
5
5
  MKPolyline *_polyline;
6
6
  CADisplayLink *_displayLink;
7
- CGFloat _animationProgress; // 0→1 grow, 1→2 shrink
7
+ CGFloat _animationProgress;
8
+ NSArray<NSNumber *> *_cumulativeDistances;
9
+ CGFloat _totalLength;
8
10
  }
9
11
 
10
12
  - (id)initWithPolyline:(MKPolyline *)polyline {
@@ -38,23 +40,47 @@
38
40
  if (_displayLink) {
39
41
  return;
40
42
  }
43
+ [self computeCumulativeDistances];
41
44
  _animationProgress = 0;
42
45
  _displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(animationTick:)];
43
46
  [_displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
44
47
  }
45
48
 
49
+ - (void)computeCumulativeDistances {
50
+ NSMutableArray<NSNumber *> *distances = [NSMutableArray array];
51
+ CGFloat total = 0;
52
+ [distances addObject:@(0)];
53
+
54
+ for (NSUInteger i = 1; i < _polyline.pointCount; i++) {
55
+ MKMapPoint p1 = _polyline.points[i - 1];
56
+ MKMapPoint p2 = _polyline.points[i];
57
+ total += MKMetersBetweenMapPoints(p1, p2);
58
+ [distances addObject:@(total)];
59
+ }
60
+
61
+ _cumulativeDistances = [distances copy];
62
+ _totalLength = total;
63
+ }
64
+
46
65
  - (void)stopAnimation {
47
66
  [_displayLink invalidate];
48
67
  _displayLink = nil;
49
68
  }
50
69
 
70
+ - (NSUInteger)indexForDistance:(CGFloat)distance {
71
+ for (NSUInteger i = 1; i < _cumulativeDistances.count; i++) {
72
+ if (_cumulativeDistances[i].doubleValue >= distance) {
73
+ return i - 1;
74
+ }
75
+ }
76
+ return _cumulativeDistances.count - 2;
77
+ }
78
+
51
79
  - (void)animationTick:(CADisplayLink *)displayLink {
52
- // ~1.75s per phase (grow or shrink), matching JS duration
53
- CGFloat speed = displayLink.duration / 1.75;
80
+ CGFloat speed = displayLink.duration / 1.0;
54
81
  _animationProgress += speed;
55
82
 
56
- // 0→1 grow, 1→2 shrink, then reset with small pause
57
- if (_animationProgress >= 2.15) { // 2.0 + 0.15 pause (~300ms at this speed)
83
+ if (_animationProgress >= 2.15) {
58
84
  _animationProgress = 0;
59
85
  }
60
86
 
@@ -67,6 +93,9 @@
67
93
  _polyline = polyline;
68
94
  [self invalidatePath];
69
95
  [self createPath];
96
+ if (_animated) {
97
+ [self computeCumulativeDistances];
98
+ }
70
99
  [self setNeedsDisplay];
71
100
  }
72
101
 
@@ -135,62 +164,64 @@
135
164
  }
136
165
 
137
166
  // Snake animation: grow from start, then shrink from start
138
- if (_animated && _polyline.pointCount > 1) {
167
+ if (_animated && _polyline.pointCount > 1 && _totalLength > 0) {
139
168
  CGFloat progress = MIN(_animationProgress, 2.0);
140
- CGFloat headPos, tailPos;
169
+ CGFloat headDist, tailDist;
141
170
 
142
171
  if (progress <= 1.0) {
143
- // Phase 1: grow from start to end
144
- tailPos = 0;
145
- headPos = progress * segmentCount;
172
+ tailDist = 0;
173
+ headDist = progress * _totalLength;
146
174
  } else {
147
- // Phase 2: shrink from start
148
175
  CGFloat shrinkProgress = progress - 1.0;
149
- tailPos = shrinkProgress * segmentCount;
150
- headPos = segmentCount;
176
+ tailDist = shrinkProgress * _totalLength;
177
+ headDist = _totalLength;
151
178
  }
152
179
 
153
- if (headPos <= tailPos) {
180
+ if (headDist <= tailDist) {
154
181
  return;
155
182
  }
156
183
 
157
- NSUInteger startIndex = (NSUInteger)floor(tailPos);
158
- NSUInteger endIndex = (NSUInteger)ceil(headPos);
159
- CGFloat visibleLength = headPos - tailPos;
184
+ CGFloat visibleLength = headDist - tailDist;
185
+ NSUInteger startIndex = [self indexForDistance:tailDist];
186
+ NSUInteger endIndex = [self indexForDistance:headDist];
187
+
188
+ for (NSUInteger i = startIndex; i <= endIndex && i < segmentCount; i++) {
189
+ CGFloat segStartDist = _cumulativeDistances[i].doubleValue;
190
+ CGFloat segEndDist = _cumulativeDistances[i + 1].doubleValue;
191
+
192
+ if (segEndDist <= tailDist || segStartDist >= headDist) {
193
+ continue;
194
+ }
160
195
 
161
- for (NSUInteger i = startIndex; i < endIndex && i < segmentCount; i++) {
162
196
  CGPoint segStart = [self pointForMapPoint:_polyline.points[i]];
163
197
  CGPoint segEnd = [self pointForMapPoint:_polyline.points[i + 1]];
164
198
 
165
199
  CGPoint drawStart = segStart;
166
200
  CGPoint drawEnd = segEnd;
167
- CGFloat segStartPos = (CGFloat)i;
168
- CGFloat segEndPos = (CGFloat)(i + 1);
201
+ CGFloat drawStartDist = segStartDist;
202
+ CGFloat drawEndDist = segEndDist;
203
+ CGFloat segLength = segEndDist - segStartDist;
169
204
 
170
- // Interpolate tail (partial segment at start)
171
- if (segStartPos < tailPos) {
172
- CGFloat t = tailPos - segStartPos;
205
+ if (segStartDist < tailDist && segLength > 0) {
206
+ CGFloat t = (tailDist - segStartDist) / segLength;
173
207
  drawStart.x = segStart.x + (segEnd.x - segStart.x) * t;
174
208
  drawStart.y = segStart.y + (segEnd.y - segStart.y) * t;
175
- segStartPos = tailPos;
209
+ drawStartDist = tailDist;
176
210
  }
177
211
 
178
- // Interpolate head (partial segment at end)
179
- if (segEndPos > headPos) {
180
- CGFloat t = headPos - (CGFloat)i;
212
+ if (segEndDist > headDist && segLength > 0) {
213
+ CGFloat t = (headDist - segStartDist) / segLength;
181
214
  drawEnd.x = segStart.x + (segEnd.x - segStart.x) * t;
182
215
  drawEnd.y = segStart.y + (segEnd.y - segStart.y) * t;
183
- segEndPos = headPos;
216
+ drawEndDist = headDist;
184
217
  }
185
218
 
186
- // Calculate gradient position (0-1) within visible portion
187
- CGFloat gradientStart = (segStartPos - tailPos) / visibleLength;
188
- CGFloat gradientEnd = (segEndPos - tailPos) / visibleLength;
219
+ CGFloat gradientStart = (drawStartDist - tailDist) / visibleLength;
220
+ CGFloat gradientEnd = (drawEndDist - tailDist) / visibleLength;
189
221
 
190
222
  UIColor *startColor = [self colorAtGradientPosition:gradientStart];
191
223
  UIColor *endColor = [self colorAtGradientPosition:gradientEnd];
192
224
 
193
- // Draw gradient line segment
194
225
  CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
195
226
  NSArray *colors = @[(__bridge id)startColor.CGColor, (__bridge id)endColor.CGColor];
196
227
  CGGradientRef gradient = CGGradientCreateWithColors(colorSpace, (__bridge CFArrayRef)colors, NULL);
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Provider component for map configuration.
5
+ * On web, wraps children with Google Maps APIProvider.
6
+ * On native, passes children through.
7
+ */
8
+ export function MapProvider({
9
+ children
10
+ }) {
11
+ return children;
12
+ }
13
+ //# sourceMappingURL=MapProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["MapProvider","children"],"sourceRoot":"../../src","sources":["MapProvider.tsx"],"mappings":";;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,WAAWA,CAAC;EAAEC;AAA2B,CAAC,EAAE;EAC1D,OAAOA,QAAQ;AACjB","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ export {};
4
+ //# sourceMappingURL=MapProvider.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../src","sources":["MapProvider.types.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ import { APIProvider } from '@vis.gl/react-google-maps';
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ export function MapProvider({
6
+ apiKey = '',
7
+ children
8
+ }) {
9
+ return /*#__PURE__*/_jsx(APIProvider, {
10
+ apiKey: apiKey,
11
+ children: children
12
+ });
13
+ }
14
+ //# sourceMappingURL=MapProvider.web.js.map
@@ -0,0 +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,SAASC,WAAWA,CAAC;EAAEC,MAAM,GAAG,EAAE;EAAEC;AAA2B,CAAC,EAAE;EACvE,oBAAOH,IAAA,CAACF,WAAW;IAACI,MAAM,EAAEA,MAAO;IAAAC,QAAA,EAAEA;EAAQ,CAAc,CAAC;AAC9D","ignoreList":[]}
@@ -35,9 +35,15 @@ export class MapView extends React.Component {
35
35
  const first = coordinates[0];
36
36
  if (!ref || !first) return;
37
37
  const {
38
- padding = 0,
38
+ padding,
39
39
  duration = -1
40
40
  } = options ?? {};
41
+ const {
42
+ top = 0,
43
+ left = 0,
44
+ bottom = 0,
45
+ right = 0
46
+ } = padding ?? {};
41
47
  if (coordinates.length === 1) {
42
48
  const zoom = this.props.initialZoom ?? 10;
43
49
  this.moveCamera(first, {
@@ -46,7 +52,7 @@ export class MapView extends React.Component {
46
52
  });
47
53
  return;
48
54
  }
49
- this.nativeCommands.fitCoordinates(ref, coordinates, padding, duration);
55
+ this.nativeCommands.fitCoordinates(ref, coordinates, top, left, bottom, right, duration);
50
56
  }
51
57
  render() {
52
58
  const {
@@ -1 +1 @@
1
- {"version":3,"names":["React","Platform","StyleSheet","LuggGoogleMapViewNativeComponent","Commands","GoogleMapCommands","LuggAppleMapViewNativeComponent","AppleMapCommands","LuggMapWrapperViewNativeComponent","jsx","_jsx","jsxs","_jsxs","MapView","Component","defaultProps","provider","OS","initialZoom","zoomEnabled","scrollEnabled","rotateEnabled","pitchEnabled","nativeRef","createRef","nativeCommands","props","isApple","moveCamera","coordinate","options","ref","current","zoom","duration","latitude","longitude","fitCoordinates","coordinates","first","padding","length","render","mapId","initialCoordinate","minZoom","maxZoom","userLocationEnabled","onCameraMove","onCameraIdle","onReady","children","rest","NativeMapView","style","absoluteFill"],"sourceRoot":"../../src","sources":["MapView.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,QAAQ,EAAEC,UAAU,QAAQ,cAAc;AACnD,OAAOC,gCAAgC,IACrCC,QAAQ,IAAIC,iBAAiB,QACxB,2CAA2C;AAClD,OAAOC,+BAA+B,IACpCF,QAAQ,IAAIG,gBAAgB,QACvB,0CAA0C;AACjD,OAAOC,iCAAiC,MAAM,4CAA4C;AAAC,SAAAC,GAAA,I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,YAAY,EAAEA,YAAa;MAC3BC,YAAY,EAAEA,YAAa;MAC3BC,OAAO,EAAEA,OAAQ;MAAAC,QAAA,gBAEjBzC,IAAA,CAACF,iCAAiC;QAAC8C,KAAK,EAAEpD,UAAU,CAACqD;MAAa,CAAE,CAAC,EACpEJ,QAAQ;IAAA,CACI,CAAC;EAEpB;AACF","ignoreList":[]}
1
+ {"version":3,"names":["React","Platform","StyleSheet","LuggGoogleMapViewNativeComponent","Commands","GoogleMapCommands","LuggAppleMapViewNativeComponent","AppleMapCommands","LuggMapWrapperViewNativeComponent","jsx","_jsx","jsxs","_jsxs","MapView","Component","defaultProps","provider","OS","initialZoom","zoomEnabled","scrollEnabled","rotateEnabled","pitchEnabled","nativeRef","createRef","nativeCommands","props","isApple","moveCamera","coordinate","options","ref","current","zoom","duration","latitude","longitude","fitCoordinates","coordinates","first","padding","top","left","bottom","right","length","render","mapId","initialCoordinate","minZoom","maxZoom","userLocationEnabled","onCameraMove","onCameraIdle","onReady","children","rest","NativeMapView","style","absoluteFill"],"sourceRoot":"../../src","sources":["MapView.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,QAAQ,EAAEC,UAAU,QAAQ,cAAc;AACnD,OAAOC,gCAAgC,IACrCC,QAAQ,IAAIC,iBAAiB,QACxB,2CAA2C;AAClD,OAAOC,+BAA+B,IACpCF,QAAQ,IAAIG,gBAAgB,QACvB,0CAA0C;AACjD,OAAOC,iCAAiC,MAAM,4CAA4C;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAS3F,OAAO,MAAMC,OAAO,SACVb,KAAK,CAACc,SAAS,CAEzB;EACE,OAAOC,YAAY,GAA0B;IAC3CC,QAAQ,EAAEf,QAAQ,CAACgB,EAAE,KAAK,KAAK,GAAG,OAAO,GAAG,QAAQ;IACpDC,WAAW,EAAE,EAAE;IACfC,WAAW,EAAE,IAAI;IACjBC,aAAa,EAAE,IAAI;IACnBC,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