@lugg/maps 0.2.0-alpha.9 → 1.0.0-beta.0

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 (173) hide show
  1. package/README.md +20 -19
  2. package/android/src/main/java/com/luggmaps/LuggMapView.kt +290 -0
  3. package/android/src/main/java/com/luggmaps/{LuggGoogleMapViewManager.kt → LuggMapViewManager.kt} +99 -36
  4. package/android/src/main/java/com/luggmaps/LuggMapWrapperView.kt +13 -5
  5. package/android/src/main/java/com/luggmaps/LuggMarkerView.kt +157 -13
  6. package/android/src/main/java/com/luggmaps/LuggMarkerViewManager.kt +28 -0
  7. package/android/src/main/java/com/luggmaps/LuggPackage.kt +1 -4
  8. package/android/src/main/java/com/luggmaps/LuggPolygonView.kt +85 -0
  9. package/android/src/main/java/com/luggmaps/LuggPolygonViewManager.kt +100 -0
  10. package/android/src/main/java/com/luggmaps/LuggPolylineView.kt +16 -0
  11. package/android/src/main/java/com/luggmaps/LuggPolylineViewManager.kt +22 -0
  12. package/android/src/main/java/com/luggmaps/core/GoogleMapProvider.kt +698 -0
  13. package/android/src/main/java/com/luggmaps/core/MapProviderDelegate.kt +60 -0
  14. package/android/src/main/java/com/luggmaps/core/PolylineAnimator.kt +89 -24
  15. package/android/src/main/java/com/luggmaps/events/LongPressEvent.kt +29 -0
  16. package/android/src/main/java/com/luggmaps/events/MarkerDragEvent.kt +41 -0
  17. package/android/src/main/java/com/luggmaps/events/MarkerPressEvent.kt +34 -0
  18. package/android/src/main/java/com/luggmaps/events/PolygonPressEvent.kt +12 -0
  19. package/android/src/main/java/com/luggmaps/events/PressEvent.kt +29 -0
  20. package/ios/LuggMapView.h +9 -0
  21. package/ios/LuggMapView.mm +343 -0
  22. package/ios/LuggMarkerView.h +13 -0
  23. package/ios/LuggMarkerView.mm +119 -0
  24. package/ios/LuggPolygonView.h +31 -0
  25. package/ios/LuggPolygonView.mm +151 -0
  26. package/ios/LuggPolylineView.h +4 -0
  27. package/ios/LuggPolylineView.mm +23 -0
  28. package/ios/core/AppleMapProvider.h +15 -0
  29. package/ios/core/AppleMapProvider.mm +1029 -0
  30. package/ios/core/GMSPolylineAnimator.h +3 -0
  31. package/ios/core/GMSPolylineAnimator.m +101 -15
  32. package/ios/core/GoogleMapProvider.h +13 -0
  33. package/ios/core/GoogleMapProvider.mm +689 -0
  34. package/ios/core/MKPolylineAnimator.h +4 -0
  35. package/ios/core/MKPolylineAnimator.m +167 -42
  36. package/ios/core/MapProviderDelegate.h +84 -0
  37. package/ios/core/PolylineAnimatorBase.h +24 -1
  38. package/ios/core/PolylineAnimatorBase.m +82 -19
  39. package/ios/events/LongPressEvent.h +29 -0
  40. package/ios/events/MarkerDragEvent.h +69 -0
  41. package/ios/events/MarkerPressEvent.h +29 -0
  42. package/ios/events/PolygonPressEvent.h +20 -0
  43. package/ios/events/PressEvent.h +29 -0
  44. package/ios/extensions/MKMapView+Zoom.h +2 -0
  45. package/ios/extensions/MKMapView+Zoom.m +14 -4
  46. package/lib/module/MapProvider.js +2 -4
  47. package/lib/module/MapProvider.js.map +1 -1
  48. package/lib/module/MapProvider.web.js +12 -7
  49. package/lib/module/MapProvider.web.js.map +1 -1
  50. package/lib/module/MapView.js +33 -16
  51. package/lib/module/MapView.js.map +1 -1
  52. package/lib/module/MapView.web.js +283 -181
  53. package/lib/module/MapView.web.js.map +1 -1
  54. package/lib/module/components/GeoJson.js +159 -0
  55. package/lib/module/components/GeoJson.js.map +1 -0
  56. package/lib/module/components/GeoJson.types.js +4 -0
  57. package/lib/module/components/GeoJson.types.js.map +1 -0
  58. package/lib/module/components/Marker.js +28 -4
  59. package/lib/module/components/Marker.js.map +1 -1
  60. package/lib/module/components/Marker.types.js +4 -0
  61. package/lib/module/components/Marker.types.js.map +1 -0
  62. package/lib/module/components/Marker.web.js +98 -27
  63. package/lib/module/components/Marker.web.js.map +1 -1
  64. package/lib/module/components/Polygon.js +46 -0
  65. package/lib/module/components/Polygon.js.map +1 -0
  66. package/lib/module/components/Polygon.types.js +4 -0
  67. package/lib/module/components/Polygon.types.js.map +1 -0
  68. package/lib/module/components/Polygon.web.js +87 -0
  69. package/lib/module/components/Polygon.web.js.map +1 -0
  70. package/lib/module/components/Polyline.js +17 -4
  71. package/lib/module/components/Polyline.js.map +1 -1
  72. package/lib/module/components/Polyline.types.js +4 -0
  73. package/lib/module/components/Polyline.types.js.map +1 -0
  74. package/lib/module/components/Polyline.web.js +108 -31
  75. package/lib/module/components/Polyline.web.js.map +1 -1
  76. package/lib/module/components/index.js +4 -2
  77. package/lib/module/components/index.js.map +1 -1
  78. package/lib/module/components/index.web.js +2 -0
  79. package/lib/module/components/index.web.js.map +1 -1
  80. package/lib/module/fabric/{LuggGoogleMapViewNativeComponent.ts → LuggMapViewNativeComponent.ts} +43 -7
  81. package/lib/module/fabric/LuggMarkerViewNativeComponent.ts +49 -1
  82. package/lib/module/fabric/LuggPolygonViewNativeComponent.ts +25 -0
  83. package/lib/module/fabric/LuggPolylineViewNativeComponent.ts +8 -0
  84. package/lib/module/index.js +4 -1
  85. package/lib/module/index.js.map +1 -1
  86. package/lib/module/index.web.js +4 -1
  87. package/lib/module/index.web.js.map +1 -1
  88. package/lib/typescript/src/MapProvider.d.ts +1 -1
  89. package/lib/typescript/src/MapProvider.d.ts.map +1 -1
  90. package/lib/typescript/src/MapProvider.web.d.ts +17 -1
  91. package/lib/typescript/src/MapProvider.web.d.ts.map +1 -1
  92. package/lib/typescript/src/MapView.d.ts +4 -4
  93. package/lib/typescript/src/MapView.d.ts.map +1 -1
  94. package/lib/typescript/src/MapView.types.d.ts +35 -9
  95. package/lib/typescript/src/MapView.types.d.ts.map +1 -1
  96. package/lib/typescript/src/MapView.web.d.ts +2 -11
  97. package/lib/typescript/src/MapView.web.d.ts.map +1 -1
  98. package/lib/typescript/src/components/GeoJson.d.ts +4 -0
  99. package/lib/typescript/src/components/GeoJson.d.ts.map +1 -0
  100. package/lib/typescript/src/components/GeoJson.types.d.ts +79 -0
  101. package/lib/typescript/src/components/GeoJson.types.d.ts.map +1 -0
  102. package/lib/typescript/src/components/Marker.d.ts +6 -33
  103. package/lib/typescript/src/components/Marker.d.ts.map +1 -1
  104. package/lib/typescript/src/components/Marker.types.d.ts +74 -0
  105. package/lib/typescript/src/components/Marker.types.d.ts.map +1 -0
  106. package/lib/typescript/src/components/Marker.web.d.ts +2 -5
  107. package/lib/typescript/src/components/Marker.web.d.ts.map +1 -1
  108. package/lib/typescript/src/components/Polygon.d.ts +10 -0
  109. package/lib/typescript/src/components/Polygon.d.ts.map +1 -0
  110. package/lib/typescript/src/components/Polygon.types.d.ts +33 -0
  111. package/lib/typescript/src/components/Polygon.types.d.ts.map +1 -0
  112. package/lib/typescript/src/components/Polygon.web.d.ts +3 -0
  113. package/lib/typescript/src/components/Polygon.web.d.ts.map +1 -0
  114. package/lib/typescript/src/components/Polyline.d.ts +6 -21
  115. package/lib/typescript/src/components/Polyline.d.ts.map +1 -1
  116. package/lib/typescript/src/components/Polyline.types.d.ts +53 -0
  117. package/lib/typescript/src/components/Polyline.types.d.ts.map +1 -0
  118. package/lib/typescript/src/components/Polyline.web.d.ts +2 -5
  119. package/lib/typescript/src/components/Polyline.web.d.ts.map +1 -1
  120. package/lib/typescript/src/components/index.d.ts +8 -2
  121. package/lib/typescript/src/components/index.d.ts.map +1 -1
  122. package/lib/typescript/src/components/index.web.d.ts +6 -2
  123. package/lib/typescript/src/components/index.web.d.ts.map +1 -1
  124. package/lib/typescript/src/fabric/{LuggGoogleMapViewNativeComponent.d.ts → LuggMapViewNativeComponent.d.ts} +30 -4
  125. package/lib/typescript/src/fabric/LuggMapViewNativeComponent.d.ts.map +1 -0
  126. package/lib/typescript/src/fabric/LuggMarkerViewNativeComponent.d.ts +45 -1
  127. package/lib/typescript/src/fabric/LuggMarkerViewNativeComponent.d.ts.map +1 -1
  128. package/lib/typescript/src/fabric/LuggPolygonViewNativeComponent.d.ts +18 -0
  129. package/lib/typescript/src/fabric/LuggPolygonViewNativeComponent.d.ts.map +1 -0
  130. package/lib/typescript/src/fabric/LuggPolylineViewNativeComponent.d.ts +7 -0
  131. package/lib/typescript/src/fabric/LuggPolylineViewNativeComponent.d.ts.map +1 -1
  132. package/lib/typescript/src/index.d.ts +11 -3
  133. package/lib/typescript/src/index.d.ts.map +1 -1
  134. package/lib/typescript/src/index.web.d.ts +9 -1
  135. package/lib/typescript/src/index.web.d.ts.map +1 -1
  136. package/lib/typescript/src/types.d.ts +11 -0
  137. package/lib/typescript/src/types.d.ts.map +1 -1
  138. package/package.json +10 -9
  139. package/src/MapProvider.tsx +1 -3
  140. package/src/MapProvider.web.tsx +12 -3
  141. package/src/MapView.tsx +32 -26
  142. package/src/MapView.types.ts +43 -9
  143. package/src/MapView.web.tsx +345 -211
  144. package/src/components/GeoJson.tsx +221 -0
  145. package/src/components/GeoJson.types.ts +107 -0
  146. package/src/components/Marker.tsx +45 -36
  147. package/src/components/Marker.types.ts +75 -0
  148. package/src/components/Marker.web.tsx +116 -28
  149. package/src/components/Polygon.tsx +52 -0
  150. package/src/components/Polygon.types.ts +33 -0
  151. package/src/components/Polygon.web.tsx +104 -0
  152. package/src/components/Polyline.tsx +23 -22
  153. package/src/components/Polyline.types.ts +55 -0
  154. package/src/components/Polyline.web.tsx +151 -37
  155. package/src/components/index.ts +16 -2
  156. package/src/components/index.web.ts +6 -2
  157. package/src/fabric/{LuggGoogleMapViewNativeComponent.ts → LuggMapViewNativeComponent.ts} +43 -7
  158. package/src/fabric/LuggMarkerViewNativeComponent.ts +49 -1
  159. package/src/fabric/LuggPolygonViewNativeComponent.ts +25 -0
  160. package/src/fabric/LuggPolylineViewNativeComponent.ts +8 -0
  161. package/src/index.ts +28 -1
  162. package/src/index.web.ts +15 -1
  163. package/src/types.ts +13 -0
  164. package/android/src/main/java/com/luggmaps/LuggGoogleMapView.kt +0 -511
  165. package/ios/LuggAppleMapView.h +0 -16
  166. package/ios/LuggAppleMapView.mm +0 -592
  167. package/ios/LuggGoogleMapView.h +0 -13
  168. package/ios/LuggGoogleMapView.mm +0 -455
  169. package/lib/module/fabric/LuggAppleMapViewNativeComponent.ts +0 -83
  170. package/lib/typescript/src/fabric/LuggAppleMapViewNativeComponent.d.ts +0 -54
  171. package/lib/typescript/src/fabric/LuggAppleMapViewNativeComponent.d.ts.map +0 -1
  172. package/lib/typescript/src/fabric/LuggGoogleMapViewNativeComponent.d.ts.map +0 -1
  173. package/src/fabric/LuggAppleMapViewNativeComponent.ts +0 -83
@@ -5,7 +5,10 @@
5
5
 
6
6
  @property(nonatomic, weak) GMSPolyline *polyline;
7
7
  @property(nonatomic, assign) BOOL animated;
8
+ @property(nonatomic, strong) PolylineAnimatedOptions *animatedOptions;
8
9
 
9
10
  - (void)update;
11
+ - (void)pause;
12
+ - (void)resume;
10
13
 
11
14
  @end
@@ -1,13 +1,44 @@
1
1
  #import "GMSPolylineAnimator.h"
2
2
  #import <QuartzCore/QuartzCore.h>
3
3
 
4
+ static const NSUInteger kMaxAnimationSpans = 16;
5
+
6
+ @interface GMSDisplayLinkProxy : NSObject
7
+ @property(nonatomic, weak) id target;
8
+ @property(nonatomic, assign) SEL selector;
9
+ @end
10
+
11
+ @implementation GMSDisplayLinkProxy
12
+ - (instancetype)initWithTarget:(id)target selector:(SEL)selector {
13
+ if (self = [super init]) {
14
+ _target = target;
15
+ _selector = selector;
16
+ }
17
+ return self;
18
+ }
19
+ - (void)tick:(CADisplayLink *)displayLink {
20
+ if (_target) {
21
+ #pragma clang diagnostic push
22
+ #pragma clang diagnostic ignored "-Warc-performSelector-leaks"
23
+ [_target performSelector:_selector withObject:displayLink];
24
+ #pragma clang diagnostic pop
25
+ } else {
26
+ [displayLink invalidate];
27
+ }
28
+ }
29
+ @end
30
+
4
31
  @implementation GMSPolylineAnimator {
5
32
  CADisplayLink *_displayLink;
33
+ GMSDisplayLinkProxy *_displayLinkProxy;
6
34
  CGFloat _animationProgress;
35
+ CGFloat _delayRemaining;
7
36
  NSArray<NSNumber *> *_cumulativeDistances;
8
37
  CGFloat _totalLength;
9
38
  }
10
39
 
40
+ @synthesize animatedOptions = _animatedOptions;
41
+
11
42
  - (void)dealloc {
12
43
  [self stopAnimation];
13
44
  }
@@ -33,13 +64,23 @@
33
64
  }
34
65
  }
35
66
 
67
+ - (void)setAnimatedOptions:(PolylineAnimatedOptions *)animatedOptions {
68
+ _animatedOptions = animatedOptions ?: [PolylineAnimatedOptions defaultOptions];
69
+ if (_animated && _displayLink) {
70
+ [self stopAnimation];
71
+ [self startAnimation];
72
+ }
73
+ }
74
+
36
75
  - (void)startAnimation {
37
76
  if (_displayLink) {
38
77
  return;
39
78
  }
40
79
  [self computeCumulativeDistances];
41
80
  _animationProgress = 0;
42
- _displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(animationTick:)];
81
+ _delayRemaining = self.animatedOptions.delay / 1000.0;
82
+ _displayLinkProxy = [[GMSDisplayLinkProxy alloc] initWithTarget:self selector:@selector(animationTick:)];
83
+ _displayLink = [CADisplayLink displayLinkWithTarget:_displayLinkProxy selector:@selector(tick:)];
43
84
  [_displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
44
85
  }
45
86
 
@@ -62,14 +103,35 @@
62
103
  - (void)stopAnimation {
63
104
  [_displayLink invalidate];
64
105
  _displayLink = nil;
106
+ _displayLinkProxy = nil;
107
+ }
108
+
109
+ - (void)pause {
110
+ _displayLink.paused = YES;
111
+ }
112
+
113
+ - (void)resume {
114
+ _displayLink.paused = NO;
65
115
  }
66
116
 
67
117
  - (void)animationTick:(CADisplayLink *)displayLink {
68
- CGFloat speed = displayLink.duration / 1.0;
118
+ if (_delayRemaining > 0) {
119
+ _delayRemaining -= displayLink.duration;
120
+ return;
121
+ }
122
+
123
+ CGFloat duration = self.animatedOptions.duration / 1000.0;
124
+ if (duration <= 0) duration = 2.15;
125
+
126
+ CGFloat trailLength = MAX(0.01, MIN(1.0, self.animatedOptions.trailLength));
127
+ CGFloat maxProgress = (trailLength < 1.0) ? 1.0 : 2.15;
128
+
129
+ CGFloat speed = displayLink.duration / duration;
69
130
  _animationProgress += speed;
70
131
 
71
- if (_animationProgress >= 2.15) {
132
+ if (_animationProgress >= maxProgress) {
72
133
  _animationProgress = 0;
134
+ _delayRemaining = self.animatedOptions.delay / 1000.0;
73
135
  }
74
136
 
75
137
  [self updateAnimatedPolyline];
@@ -98,12 +160,19 @@
98
160
  }
99
161
 
100
162
  - (NSUInteger)indexForDistance:(CGFloat)distance {
101
- for (NSUInteger i = 1; i < _cumulativeDistances.count; i++) {
102
- if (_cumulativeDistances[i].doubleValue >= distance) {
103
- return i - 1;
163
+ NSUInteger left = 0;
164
+ NSUInteger right = _cumulativeDistances.count - 1;
165
+
166
+ while (left < right) {
167
+ NSUInteger mid = (left + right + 1) / 2;
168
+ if (_cumulativeDistances[mid].doubleValue <= distance) {
169
+ left = mid;
170
+ } else {
171
+ right = mid - 1;
104
172
  }
105
173
  }
106
- return _cumulativeDistances.count - 2;
174
+
175
+ return MIN(left, _cumulativeDistances.count - 2);
107
176
  }
108
177
 
109
178
  - (CLLocationCoordinate2D)coordinateAtDistance:(CGFloat)distance {
@@ -132,14 +201,21 @@
132
201
  return;
133
202
  }
134
203
 
135
- CGFloat progress = MIN(_animationProgress, 2.0);
204
+ CGFloat trailLength = MAX(0.01, MIN(1.0, self.animatedOptions.trailLength));
205
+ CGFloat maxProgress = (trailLength < 1.0) ? 1.0 : 2.0;
206
+ CGFloat progress = MIN(_animationProgress, maxProgress);
207
+ CGFloat easedProgress = [self applyEasing:progress / maxProgress] * maxProgress;
208
+
136
209
  CGFloat headDist, tailDist;
137
210
 
138
- if (progress <= 1.0) {
211
+ if (trailLength < 1.0) {
212
+ headDist = easedProgress * _totalLength;
213
+ tailDist = MAX(0, headDist - _totalLength * trailLength);
214
+ } else if (easedProgress <= 1.0) {
139
215
  tailDist = 0;
140
- headDist = progress * _totalLength;
216
+ headDist = easedProgress * _totalLength;
141
217
  } else {
142
- CGFloat shrinkProgress = progress - 1.0;
218
+ CGFloat shrinkProgress = easedProgress - 1.0;
143
219
  tailDist = shrinkProgress * _totalLength;
144
220
  headDist = _totalLength;
145
221
  }
@@ -171,12 +247,22 @@
171
247
  }
172
248
 
173
249
  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;
250
+ NSUInteger segmentCount = pathCount - 1;
251
+
252
+ if (self.strokeColors.count <= 1) {
253
+ _polyline.path = path;
254
+ _polyline.strokeColor = self.strokeColors.firstObject ?: [UIColor blackColor];
255
+ return;
256
+ }
257
+
258
+ NSUInteger spanCount = MIN(segmentCount, kMaxAnimationSpans);
259
+ double segmentsPerSpan = (double)segmentCount / spanCount;
260
+
261
+ for (NSUInteger i = 0; i < spanCount; i++) {
262
+ CGFloat gradientPos = ((CGFloat)i + 0.5) / spanCount;
177
263
  UIColor *color = [self colorAtGradientPosition:gradientPos];
178
264
  GMSStrokeStyle *style = [GMSStrokeStyle solidColor:color];
179
- [spans addObject:[GMSStyleSpan spanWithStyle:style]];
265
+ [spans addObject:[GMSStyleSpan spanWithStyle:style segments:segmentsPerSpan]];
180
266
  }
181
267
 
182
268
  _polyline.path = path;
@@ -0,0 +1,13 @@
1
+ #import "MapProviderDelegate.h"
2
+ #import <GoogleMaps/GoogleMaps.h>
3
+
4
+ NS_ASSUME_NONNULL_BEGIN
5
+
6
+ @interface GoogleMapProvider : NSObject <MapProvider, GMSMapViewDelegate>
7
+
8
+ @property(nonatomic, copy, nullable) NSString *mapId;
9
+ @property(nonatomic, readonly, nullable) GMSMapView *mapView;
10
+
11
+ @end
12
+
13
+ NS_ASSUME_NONNULL_END