@lugg/maps 0.2.0-alpha.8 → 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.
- package/README.md +20 -19
- package/android/src/main/java/com/luggmaps/LuggMapView.kt +290 -0
- package/android/src/main/java/com/luggmaps/{LuggGoogleMapViewManager.kt → LuggMapViewManager.kt} +99 -36
- package/android/src/main/java/com/luggmaps/LuggMapWrapperView.kt +13 -5
- package/android/src/main/java/com/luggmaps/LuggMarkerView.kt +157 -13
- package/android/src/main/java/com/luggmaps/LuggMarkerViewManager.kt +28 -0
- package/android/src/main/java/com/luggmaps/LuggPackage.kt +1 -4
- package/android/src/main/java/com/luggmaps/LuggPolygonView.kt +85 -0
- package/android/src/main/java/com/luggmaps/LuggPolygonViewManager.kt +100 -0
- package/android/src/main/java/com/luggmaps/LuggPolylineView.kt +16 -0
- package/android/src/main/java/com/luggmaps/LuggPolylineViewManager.kt +22 -0
- package/android/src/main/java/com/luggmaps/core/GoogleMapProvider.kt +698 -0
- package/android/src/main/java/com/luggmaps/core/MapProviderDelegate.kt +60 -0
- package/android/src/main/java/com/luggmaps/core/PolylineAnimator.kt +89 -24
- package/android/src/main/java/com/luggmaps/events/LongPressEvent.kt +29 -0
- package/android/src/main/java/com/luggmaps/events/MarkerDragEvent.kt +41 -0
- package/android/src/main/java/com/luggmaps/events/MarkerPressEvent.kt +34 -0
- package/android/src/main/java/com/luggmaps/events/PolygonPressEvent.kt +12 -0
- package/android/src/main/java/com/luggmaps/events/PressEvent.kt +29 -0
- package/ios/LuggMapView.h +9 -0
- package/ios/LuggMapView.mm +343 -0
- package/ios/LuggMarkerView.h +13 -0
- package/ios/LuggMarkerView.mm +119 -0
- package/ios/LuggPolygonView.h +31 -0
- package/ios/LuggPolygonView.mm +151 -0
- package/ios/LuggPolylineView.h +4 -0
- package/ios/LuggPolylineView.mm +23 -0
- package/ios/core/AppleMapProvider.h +15 -0
- package/ios/core/AppleMapProvider.mm +1029 -0
- package/ios/core/GMSPolylineAnimator.h +3 -0
- package/ios/core/GMSPolylineAnimator.m +101 -15
- package/ios/core/GoogleMapProvider.h +13 -0
- package/ios/core/GoogleMapProvider.mm +689 -0
- package/ios/core/MKPolylineAnimator.h +4 -0
- package/ios/core/MKPolylineAnimator.m +167 -42
- package/ios/core/MapProviderDelegate.h +84 -0
- package/ios/core/PolylineAnimatorBase.h +24 -1
- package/ios/core/PolylineAnimatorBase.m +82 -19
- package/ios/events/LongPressEvent.h +29 -0
- package/ios/events/MarkerDragEvent.h +69 -0
- package/ios/events/MarkerPressEvent.h +29 -0
- package/ios/events/PolygonPressEvent.h +20 -0
- package/ios/events/PressEvent.h +29 -0
- package/ios/extensions/MKMapView+Zoom.h +2 -0
- package/ios/extensions/MKMapView+Zoom.m +14 -4
- package/lib/module/MapProvider.js +2 -4
- package/lib/module/MapProvider.js.map +1 -1
- package/lib/module/MapProvider.web.js +12 -7
- package/lib/module/MapProvider.web.js.map +1 -1
- package/lib/module/MapView.js +33 -16
- package/lib/module/MapView.js.map +1 -1
- package/lib/module/MapView.web.js +315 -217
- package/lib/module/MapView.web.js.map +1 -1
- package/lib/module/components/GeoJson.js +159 -0
- package/lib/module/components/GeoJson.js.map +1 -0
- package/lib/module/components/GeoJson.types.js +4 -0
- package/lib/module/components/GeoJson.types.js.map +1 -0
- package/lib/module/components/Marker.js +28 -4
- package/lib/module/components/Marker.js.map +1 -1
- package/lib/module/components/Marker.types.js +4 -0
- package/lib/module/components/Marker.types.js.map +1 -0
- package/lib/module/components/Marker.web.js +98 -27
- package/lib/module/components/Marker.web.js.map +1 -1
- package/lib/module/components/Polygon.js +46 -0
- package/lib/module/components/Polygon.js.map +1 -0
- package/lib/module/components/Polygon.types.js +4 -0
- package/lib/module/components/Polygon.types.js.map +1 -0
- package/lib/module/components/Polygon.web.js +87 -0
- package/lib/module/components/Polygon.web.js.map +1 -0
- package/lib/module/components/Polyline.js +17 -4
- package/lib/module/components/Polyline.js.map +1 -1
- package/lib/module/components/Polyline.types.js +4 -0
- package/lib/module/components/Polyline.types.js.map +1 -0
- package/lib/module/components/Polyline.web.js +108 -31
- package/lib/module/components/Polyline.web.js.map +1 -1
- package/lib/module/components/index.js +4 -2
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/components/index.web.js +2 -0
- package/lib/module/components/index.web.js.map +1 -1
- package/lib/module/fabric/{LuggGoogleMapViewNativeComponent.ts → LuggMapViewNativeComponent.ts} +43 -7
- package/lib/module/fabric/LuggMarkerViewNativeComponent.ts +49 -1
- package/lib/module/fabric/LuggPolygonViewNativeComponent.ts +25 -0
- package/lib/module/fabric/LuggPolylineViewNativeComponent.ts +8 -0
- package/lib/module/index.js +4 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js +4 -1
- package/lib/module/index.web.js.map +1 -1
- package/lib/typescript/src/MapProvider.d.ts +1 -1
- package/lib/typescript/src/MapProvider.d.ts.map +1 -1
- package/lib/typescript/src/MapProvider.web.d.ts +17 -1
- package/lib/typescript/src/MapProvider.web.d.ts.map +1 -1
- package/lib/typescript/src/MapView.d.ts +4 -4
- package/lib/typescript/src/MapView.d.ts.map +1 -1
- package/lib/typescript/src/MapView.types.d.ts +35 -9
- package/lib/typescript/src/MapView.types.d.ts.map +1 -1
- package/lib/typescript/src/MapView.web.d.ts +2 -11
- package/lib/typescript/src/MapView.web.d.ts.map +1 -1
- package/lib/typescript/src/components/GeoJson.d.ts +4 -0
- package/lib/typescript/src/components/GeoJson.d.ts.map +1 -0
- package/lib/typescript/src/components/GeoJson.types.d.ts +79 -0
- package/lib/typescript/src/components/GeoJson.types.d.ts.map +1 -0
- package/lib/typescript/src/components/Marker.d.ts +6 -33
- package/lib/typescript/src/components/Marker.d.ts.map +1 -1
- package/lib/typescript/src/components/Marker.types.d.ts +74 -0
- package/lib/typescript/src/components/Marker.types.d.ts.map +1 -0
- package/lib/typescript/src/components/Marker.web.d.ts +2 -5
- package/lib/typescript/src/components/Marker.web.d.ts.map +1 -1
- package/lib/typescript/src/components/Polygon.d.ts +10 -0
- package/lib/typescript/src/components/Polygon.d.ts.map +1 -0
- package/lib/typescript/src/components/Polygon.types.d.ts +33 -0
- package/lib/typescript/src/components/Polygon.types.d.ts.map +1 -0
- package/lib/typescript/src/components/Polygon.web.d.ts +3 -0
- package/lib/typescript/src/components/Polygon.web.d.ts.map +1 -0
- package/lib/typescript/src/components/Polyline.d.ts +6 -21
- package/lib/typescript/src/components/Polyline.d.ts.map +1 -1
- package/lib/typescript/src/components/Polyline.types.d.ts +53 -0
- package/lib/typescript/src/components/Polyline.types.d.ts.map +1 -0
- package/lib/typescript/src/components/Polyline.web.d.ts +2 -5
- package/lib/typescript/src/components/Polyline.web.d.ts.map +1 -1
- package/lib/typescript/src/components/index.d.ts +8 -2
- package/lib/typescript/src/components/index.d.ts.map +1 -1
- package/lib/typescript/src/components/index.web.d.ts +6 -2
- package/lib/typescript/src/components/index.web.d.ts.map +1 -1
- package/lib/typescript/src/fabric/{LuggGoogleMapViewNativeComponent.d.ts → LuggMapViewNativeComponent.d.ts} +30 -4
- package/lib/typescript/src/fabric/LuggMapViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/fabric/LuggMarkerViewNativeComponent.d.ts +45 -1
- package/lib/typescript/src/fabric/LuggMarkerViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/fabric/LuggPolygonViewNativeComponent.d.ts +18 -0
- package/lib/typescript/src/fabric/LuggPolygonViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/fabric/LuggPolylineViewNativeComponent.d.ts +7 -0
- package/lib/typescript/src/fabric/LuggPolylineViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +11 -3
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/index.web.d.ts +9 -1
- package/lib/typescript/src/index.web.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +11 -0
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/package.json +10 -9
- package/src/MapProvider.tsx +1 -3
- package/src/MapProvider.web.tsx +12 -3
- package/src/MapView.tsx +32 -26
- package/src/MapView.types.ts +43 -9
- package/src/MapView.web.tsx +376 -244
- package/src/components/GeoJson.tsx +221 -0
- package/src/components/GeoJson.types.ts +107 -0
- package/src/components/Marker.tsx +45 -36
- package/src/components/Marker.types.ts +75 -0
- package/src/components/Marker.web.tsx +116 -28
- package/src/components/Polygon.tsx +52 -0
- package/src/components/Polygon.types.ts +33 -0
- package/src/components/Polygon.web.tsx +104 -0
- package/src/components/Polyline.tsx +23 -22
- package/src/components/Polyline.types.ts +55 -0
- package/src/components/Polyline.web.tsx +151 -37
- package/src/components/index.ts +16 -2
- package/src/components/index.web.ts +6 -2
- package/src/fabric/{LuggGoogleMapViewNativeComponent.ts → LuggMapViewNativeComponent.ts} +43 -7
- package/src/fabric/LuggMarkerViewNativeComponent.ts +49 -1
- package/src/fabric/LuggPolygonViewNativeComponent.ts +25 -0
- package/src/fabric/LuggPolylineViewNativeComponent.ts +8 -0
- package/src/index.ts +28 -1
- package/src/index.web.ts +15 -1
- package/src/types.ts +13 -0
- package/android/src/main/java/com/luggmaps/LuggGoogleMapView.kt +0 -511
- package/ios/LuggAppleMapView.h +0 -16
- package/ios/LuggAppleMapView.mm +0 -592
- package/ios/LuggGoogleMapView.h +0 -13
- package/ios/LuggGoogleMapView.mm +0 -455
- package/lib/module/fabric/LuggAppleMapViewNativeComponent.ts +0 -83
- package/lib/typescript/src/fabric/LuggAppleMapViewNativeComponent.d.ts +0 -54
- package/lib/typescript/src/fabric/LuggAppleMapViewNativeComponent.d.ts.map +0 -1
- package/lib/typescript/src/fabric/LuggGoogleMapViewNativeComponent.d.ts.map +0 -1
- package/src/fabric/LuggAppleMapViewNativeComponent.ts +0 -83
|
@@ -1,12 +1,42 @@
|
|
|
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;
|
|
34
|
+
CGFloat _delayRemaining;
|
|
8
35
|
NSArray<NSNumber *> *_cumulativeDistances;
|
|
9
36
|
CGFloat _totalLength;
|
|
37
|
+
CGColorSpaceRef _colorSpace;
|
|
38
|
+
RGBAComponents *_colorCache;
|
|
39
|
+
NSUInteger _colorCacheCount;
|
|
10
40
|
}
|
|
11
41
|
|
|
12
42
|
- (id)initWithPolyline:(MKPolyline *)polyline {
|
|
@@ -14,13 +44,28 @@
|
|
|
14
44
|
if (self) {
|
|
15
45
|
_polyline = polyline;
|
|
16
46
|
_animationProgress = 0;
|
|
47
|
+
_animatedOptions = [PolylineAnimatedOptions defaultOptions];
|
|
48
|
+
_colorSpace = CGColorSpaceCreateDeviceRGB();
|
|
17
49
|
[self createPath];
|
|
18
50
|
}
|
|
19
51
|
return self;
|
|
20
52
|
}
|
|
21
53
|
|
|
54
|
+
- (void)setAnimatedOptions:(PolylineAnimatedOptions *)animatedOptions {
|
|
55
|
+
_animatedOptions = animatedOptions ?: [PolylineAnimatedOptions defaultOptions];
|
|
56
|
+
if (_animated && _displayLink) {
|
|
57
|
+
[self stopAnimation];
|
|
58
|
+
[self startAnimation];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
22
62
|
- (void)dealloc {
|
|
23
63
|
[self stopAnimation];
|
|
64
|
+
free(_colorCache);
|
|
65
|
+
if (_colorSpace) {
|
|
66
|
+
CGColorSpaceRelease(_colorSpace);
|
|
67
|
+
_colorSpace = NULL;
|
|
68
|
+
}
|
|
24
69
|
}
|
|
25
70
|
|
|
26
71
|
- (void)setAnimated:(BOOL)animated {
|
|
@@ -42,7 +87,9 @@
|
|
|
42
87
|
}
|
|
43
88
|
[self computeCumulativeDistances];
|
|
44
89
|
_animationProgress = 0;
|
|
45
|
-
|
|
90
|
+
_delayRemaining = _animatedOptions.delay / 1000.0;
|
|
91
|
+
_displayLinkProxy = [[MKDisplayLinkProxy alloc] initWithTarget:self selector:@selector(animationTick:)];
|
|
92
|
+
_displayLink = [CADisplayLink displayLinkWithTarget:_displayLinkProxy selector:@selector(tick:)];
|
|
46
93
|
[_displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
|
|
47
94
|
}
|
|
48
95
|
|
|
@@ -65,23 +112,64 @@
|
|
|
65
112
|
- (void)stopAnimation {
|
|
66
113
|
[_displayLink invalidate];
|
|
67
114
|
_displayLink = nil;
|
|
115
|
+
_displayLinkProxy = nil;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
- (void)pause {
|
|
119
|
+
_displayLink.paused = YES;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
- (void)resume {
|
|
123
|
+
_displayLink.paused = NO;
|
|
68
124
|
}
|
|
69
125
|
|
|
70
126
|
- (NSUInteger)indexForDistance:(CGFloat)distance {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
127
|
+
NSUInteger left = 0;
|
|
128
|
+
NSUInteger right = _cumulativeDistances.count - 1;
|
|
129
|
+
|
|
130
|
+
while (left < right) {
|
|
131
|
+
NSUInteger mid = (left + right + 1) / 2;
|
|
132
|
+
if (_cumulativeDistances[mid].doubleValue <= distance) {
|
|
133
|
+
left = mid;
|
|
134
|
+
} else {
|
|
135
|
+
right = mid - 1;
|
|
74
136
|
}
|
|
75
137
|
}
|
|
76
|
-
|
|
138
|
+
|
|
139
|
+
return MIN(left, _cumulativeDistances.count - 2);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
- (CGFloat)applyEasing:(CGFloat)t {
|
|
143
|
+
NSString *easing = _animatedOptions.easing ?: @"linear";
|
|
144
|
+
|
|
145
|
+
if ([easing isEqualToString:@"easeIn"]) {
|
|
146
|
+
return t * t;
|
|
147
|
+
} else if ([easing isEqualToString:@"easeOut"]) {
|
|
148
|
+
return t * (2 - t);
|
|
149
|
+
} else if ([easing isEqualToString:@"easeInOut"]) {
|
|
150
|
+
return t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
|
|
151
|
+
}
|
|
152
|
+
return t;
|
|
77
153
|
}
|
|
78
154
|
|
|
79
155
|
- (void)animationTick:(CADisplayLink *)displayLink {
|
|
80
|
-
|
|
156
|
+
if (_delayRemaining > 0) {
|
|
157
|
+
_delayRemaining -= displayLink.duration;
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
CGFloat duration = _animatedOptions.duration / 1000.0;
|
|
162
|
+
if (duration <= 0) duration = 2.15;
|
|
163
|
+
|
|
164
|
+
CGFloat trailLength = MAX(0.01, MIN(1.0, _animatedOptions.trailLength));
|
|
165
|
+
CGFloat maxProgress = (trailLength < 1.0) ? 1.0 : 2.15;
|
|
166
|
+
|
|
167
|
+
CGFloat speed = displayLink.duration / duration;
|
|
81
168
|
_animationProgress += speed;
|
|
82
169
|
|
|
83
|
-
if (_animationProgress >=
|
|
170
|
+
if (_animationProgress >= maxProgress) {
|
|
84
171
|
_animationProgress = 0;
|
|
172
|
+
_delayRemaining = _animatedOptions.delay / 1000.0;
|
|
85
173
|
}
|
|
86
174
|
|
|
87
175
|
MKMapRect bounds = _polyline.boundingMapRect;
|
|
@@ -114,34 +202,60 @@
|
|
|
114
202
|
self.path = path;
|
|
115
203
|
}
|
|
116
204
|
|
|
117
|
-
- (UIColor *)
|
|
118
|
-
|
|
119
|
-
|
|
205
|
+
- (void)setStrokeColors:(NSArray<UIColor *> *)strokeColors {
|
|
206
|
+
_strokeColors = strokeColors;
|
|
207
|
+
[self rebuildColorCache];
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
- (void)rebuildColorCache {
|
|
211
|
+
free(_colorCache);
|
|
212
|
+
_colorCache = NULL;
|
|
213
|
+
_colorCacheCount = _strokeColors.count;
|
|
214
|
+
if (_colorCacheCount == 0) return;
|
|
215
|
+
|
|
216
|
+
_colorCache = (RGBAComponents *)malloc(sizeof(RGBAComponents) * _colorCacheCount);
|
|
217
|
+
for (NSUInteger i = 0; i < _colorCacheCount; i++) {
|
|
218
|
+
[_strokeColors[i] getRed:&_colorCache[i].r
|
|
219
|
+
green:&_colorCache[i].g
|
|
220
|
+
blue:&_colorCache[i].b
|
|
221
|
+
alpha:&_colorCache[i].a];
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
- (void)colorAtGradientPosition:(CGFloat)position rgba:(RGBAComponents *)out {
|
|
226
|
+
if (_colorCacheCount == 0) {
|
|
227
|
+
CGFloat r, g, b, a;
|
|
228
|
+
[self.strokeColor getRed:&r green:&g blue:&b alpha:&a];
|
|
229
|
+
*out = (RGBAComponents){r, g, b, a};
|
|
230
|
+
return;
|
|
120
231
|
}
|
|
121
|
-
if (
|
|
122
|
-
|
|
232
|
+
if (_colorCacheCount == 1) {
|
|
233
|
+
*out = _colorCache[0];
|
|
234
|
+
return;
|
|
123
235
|
}
|
|
124
236
|
|
|
125
237
|
position = MAX(0, MIN(1, position));
|
|
126
|
-
CGFloat scaledPos = position * (
|
|
127
|
-
NSUInteger index = (NSUInteger)
|
|
238
|
+
CGFloat scaledPos = position * (_colorCacheCount - 1);
|
|
239
|
+
NSUInteger index = (NSUInteger)scaledPos;
|
|
128
240
|
CGFloat t = scaledPos - index;
|
|
129
241
|
|
|
130
|
-
if (index >=
|
|
131
|
-
|
|
242
|
+
if (index >= _colorCacheCount - 1) {
|
|
243
|
+
*out = _colorCache[_colorCacheCount - 1];
|
|
244
|
+
return;
|
|
132
245
|
}
|
|
133
246
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
247
|
+
RGBAComponents c1 = _colorCache[index];
|
|
248
|
+
RGBAComponents c2 = _colorCache[index + 1];
|
|
249
|
+
out->r = c1.r + (c2.r - c1.r) * t;
|
|
250
|
+
out->g = c1.g + (c2.g - c1.g) * t;
|
|
251
|
+
out->b = c1.b + (c2.b - c1.b) * t;
|
|
252
|
+
out->a = c1.a + (c2.a - c1.a) * t;
|
|
253
|
+
}
|
|
140
254
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
255
|
+
- (UIColor *)colorAtGradientPosition:(CGFloat)position {
|
|
256
|
+
RGBAComponents rgba;
|
|
257
|
+
[self colorAtGradientPosition:position rgba:&rgba];
|
|
258
|
+
return [UIColor colorWithRed:rgba.r green:rgba.g blue:rgba.b alpha:rgba.a];
|
|
145
259
|
}
|
|
146
260
|
|
|
147
261
|
- (void)drawMapRect:(MKMapRect)mapRect
|
|
@@ -165,14 +279,21 @@
|
|
|
165
279
|
|
|
166
280
|
// Snake animation: grow from start, then shrink from start
|
|
167
281
|
if (_animated && _polyline.pointCount > 1 && _totalLength > 0) {
|
|
168
|
-
CGFloat
|
|
282
|
+
CGFloat trailLength = MAX(0.01, MIN(1.0, _animatedOptions.trailLength));
|
|
283
|
+
CGFloat maxProgress = (trailLength < 1.0) ? 1.0 : 2.0;
|
|
284
|
+
CGFloat progress = MIN(_animationProgress, maxProgress);
|
|
285
|
+
CGFloat easedProgress = [self applyEasing:progress / maxProgress] * maxProgress;
|
|
286
|
+
|
|
169
287
|
CGFloat headDist, tailDist;
|
|
170
288
|
|
|
171
|
-
if (
|
|
289
|
+
if (trailLength < 1.0) {
|
|
290
|
+
headDist = easedProgress * _totalLength;
|
|
291
|
+
tailDist = MAX(0, headDist - _totalLength * trailLength);
|
|
292
|
+
} else if (easedProgress <= 1.0) {
|
|
172
293
|
tailDist = 0;
|
|
173
|
-
headDist =
|
|
294
|
+
headDist = easedProgress * _totalLength;
|
|
174
295
|
} else {
|
|
175
|
-
CGFloat shrinkProgress =
|
|
296
|
+
CGFloat shrinkProgress = easedProgress - 1.0;
|
|
176
297
|
tailDist = shrinkProgress * _totalLength;
|
|
177
298
|
headDist = _totalLength;
|
|
178
299
|
}
|
|
@@ -219,12 +340,15 @@
|
|
|
219
340
|
CGFloat gradientStart = (drawStartDist - tailDist) / visibleLength;
|
|
220
341
|
CGFloat gradientEnd = (drawEndDist - tailDist) / visibleLength;
|
|
221
342
|
|
|
222
|
-
|
|
223
|
-
|
|
343
|
+
RGBAComponents startRGBA, endRGBA;
|
|
344
|
+
[self colorAtGradientPosition:gradientStart rgba:&startRGBA];
|
|
345
|
+
[self colorAtGradientPosition:gradientEnd rgba:&endRGBA];
|
|
224
346
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
347
|
+
CGFloat components[] = {
|
|
348
|
+
startRGBA.r, startRGBA.g, startRGBA.b, startRGBA.a,
|
|
349
|
+
endRGBA.r, endRGBA.g, endRGBA.b, endRGBA.a
|
|
350
|
+
};
|
|
351
|
+
CGGradientRef gradient = CGGradientCreateWithColorComponents(_colorSpace, components, NULL, 2);
|
|
228
352
|
|
|
229
353
|
CGContextSaveGState(context);
|
|
230
354
|
CGContextBeginPath(context);
|
|
@@ -237,7 +361,6 @@
|
|
|
237
361
|
|
|
238
362
|
CGContextRestoreGState(context);
|
|
239
363
|
CGGradientRelease(gradient);
|
|
240
|
-
CGColorSpaceRelease(colorSpace);
|
|
241
364
|
}
|
|
242
365
|
return;
|
|
243
366
|
}
|
|
@@ -251,12 +374,15 @@
|
|
|
251
374
|
CGFloat gradientStart = (CGFloat)i / segmentCount;
|
|
252
375
|
CGFloat gradientEnd = (CGFloat)(i + 1) / segmentCount;
|
|
253
376
|
|
|
254
|
-
|
|
255
|
-
|
|
377
|
+
RGBAComponents startRGBA, endRGBA;
|
|
378
|
+
[self colorAtGradientPosition:gradientStart rgba:&startRGBA];
|
|
379
|
+
[self colorAtGradientPosition:gradientEnd rgba:&endRGBA];
|
|
256
380
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
381
|
+
CGFloat components[] = {
|
|
382
|
+
startRGBA.r, startRGBA.g, startRGBA.b, startRGBA.a,
|
|
383
|
+
endRGBA.r, endRGBA.g, endRGBA.b, endRGBA.a
|
|
384
|
+
};
|
|
385
|
+
CGGradientRef gradient = CGGradientCreateWithColorComponents(_colorSpace, components, NULL, 2);
|
|
260
386
|
|
|
261
387
|
CGContextSaveGState(context);
|
|
262
388
|
CGContextBeginPath(context);
|
|
@@ -269,7 +395,6 @@
|
|
|
269
395
|
|
|
270
396
|
CGContextRestoreGState(context);
|
|
271
397
|
CGGradientRelease(gradient);
|
|
272
|
-
CGColorSpaceRelease(colorSpace);
|
|
273
398
|
}
|
|
274
399
|
return;
|
|
275
400
|
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
#import <CoreLocation/CoreLocation.h>
|
|
2
|
+
#import <UIKit/UIKit.h>
|
|
3
|
+
|
|
4
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
5
|
+
|
|
6
|
+
@class LuggMarkerView;
|
|
7
|
+
@class LuggPolylineView;
|
|
8
|
+
@class LuggPolygonView;
|
|
9
|
+
|
|
10
|
+
@protocol MapProviderDelegate <NSObject>
|
|
11
|
+
- (void)mapProviderDidReady;
|
|
12
|
+
- (void)mapProviderDidMoveCamera:(double)latitude
|
|
13
|
+
longitude:(double)longitude
|
|
14
|
+
zoom:(double)zoom
|
|
15
|
+
gesture:(BOOL)gesture;
|
|
16
|
+
- (void)mapProviderDidIdleCamera:(double)latitude
|
|
17
|
+
longitude:(double)longitude
|
|
18
|
+
zoom:(double)zoom
|
|
19
|
+
gesture:(BOOL)gesture;
|
|
20
|
+
- (void)mapProviderDidPress:(double)latitude
|
|
21
|
+
longitude:(double)longitude
|
|
22
|
+
x:(double)x
|
|
23
|
+
y:(double)y;
|
|
24
|
+
- (void)mapProviderDidLongPress:(double)latitude
|
|
25
|
+
longitude:(double)longitude
|
|
26
|
+
x:(double)x
|
|
27
|
+
y:(double)y;
|
|
28
|
+
@end
|
|
29
|
+
|
|
30
|
+
@protocol MapProvider <NSObject>
|
|
31
|
+
|
|
32
|
+
@property(nonatomic, weak, nullable) id<MapProviderDelegate> delegate;
|
|
33
|
+
@property(nonatomic, readonly) BOOL isMapReady;
|
|
34
|
+
|
|
35
|
+
- (void)initializeMapInView:(UIView *)wrapperView
|
|
36
|
+
initialCoordinate:(CLLocationCoordinate2D)coordinate
|
|
37
|
+
initialZoom:(double)zoom;
|
|
38
|
+
- (void)destroy;
|
|
39
|
+
|
|
40
|
+
// Props
|
|
41
|
+
- (void)setZoomEnabled:(BOOL)enabled;
|
|
42
|
+
- (void)setScrollEnabled:(BOOL)enabled;
|
|
43
|
+
- (void)setRotateEnabled:(BOOL)enabled;
|
|
44
|
+
- (void)setPitchEnabled:(BOOL)enabled;
|
|
45
|
+
- (void)setUserLocationEnabled:(BOOL)enabled;
|
|
46
|
+
- (void)setTheme:(NSInteger)theme;
|
|
47
|
+
- (void)setMinZoom:(double)minZoom;
|
|
48
|
+
- (void)setMaxZoom:(double)maxZoom;
|
|
49
|
+
- (void)setEdgeInsets:(UIEdgeInsets)edgeInsets
|
|
50
|
+
oldEdgeInsets:(UIEdgeInsets)oldEdgeInsets;
|
|
51
|
+
- (void)setEdgeInsets:(UIEdgeInsets)edgeInsets
|
|
52
|
+
oldEdgeInsets:(UIEdgeInsets)oldEdgeInsets
|
|
53
|
+
duration:(double)duration;
|
|
54
|
+
|
|
55
|
+
// Children
|
|
56
|
+
- (void)addMarkerView:(LuggMarkerView *)markerView;
|
|
57
|
+
- (void)removeMarkerView:(LuggMarkerView *)markerView;
|
|
58
|
+
- (void)syncMarkerView:(LuggMarkerView *)markerView;
|
|
59
|
+
- (void)addPolylineView:(LuggPolylineView *)polylineView;
|
|
60
|
+
- (void)removePolylineView:(LuggPolylineView *)polylineView;
|
|
61
|
+
- (void)syncPolylineView:(LuggPolylineView *)polylineView;
|
|
62
|
+
- (void)addPolygonView:(LuggPolygonView *)polygonView;
|
|
63
|
+
- (void)removePolygonView:(LuggPolygonView *)polygonView;
|
|
64
|
+
- (void)syncPolygonView:(LuggPolygonView *)polygonView;
|
|
65
|
+
|
|
66
|
+
// Lifecycle
|
|
67
|
+
- (void)pauseAnimations;
|
|
68
|
+
- (void)resumeAnimations;
|
|
69
|
+
|
|
70
|
+
// Commands
|
|
71
|
+
- (void)moveCamera:(double)latitude
|
|
72
|
+
longitude:(double)longitude
|
|
73
|
+
zoom:(double)zoom
|
|
74
|
+
duration:(double)duration;
|
|
75
|
+
- (void)fitCoordinates:(NSArray *)coordinates
|
|
76
|
+
edgeInsetsTop:(double)edgeInsetsTop
|
|
77
|
+
edgeInsetsLeft:(double)edgeInsetsLeft
|
|
78
|
+
edgeInsetsBottom:(double)edgeInsetsBottom
|
|
79
|
+
edgeInsetsRight:(double)edgeInsetsRight
|
|
80
|
+
duration:(double)duration;
|
|
81
|
+
|
|
82
|
+
@end
|
|
83
|
+
|
|
84
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -2,21 +2,44 @@
|
|
|
2
2
|
#import <Foundation/Foundation.h>
|
|
3
3
|
#import <UIKit/UIKit.h>
|
|
4
4
|
|
|
5
|
+
@interface PolylineAnimatedOptions : NSObject
|
|
6
|
+
|
|
7
|
+
@property(nonatomic, assign) NSTimeInterval duration;
|
|
8
|
+
@property(nonatomic, copy) NSString *easing;
|
|
9
|
+
@property(nonatomic, assign) CGFloat trailLength;
|
|
10
|
+
@property(nonatomic, assign) NSTimeInterval delay;
|
|
11
|
+
|
|
12
|
+
+ (instancetype)defaultOptions;
|
|
13
|
+
|
|
14
|
+
@end
|
|
15
|
+
|
|
5
16
|
@protocol PolylineAnimator <NSObject>
|
|
6
17
|
|
|
7
18
|
@property(nonatomic, strong) NSArray<CLLocation *> *coordinates;
|
|
8
19
|
@property(nonatomic, strong) NSArray<UIColor *> *strokeColors;
|
|
9
20
|
@property(nonatomic, assign) BOOL animated;
|
|
21
|
+
@property(nonatomic, strong) PolylineAnimatedOptions *animatedOptions;
|
|
10
22
|
|
|
11
23
|
- (void)update;
|
|
12
24
|
|
|
13
25
|
@end
|
|
14
26
|
|
|
15
|
-
|
|
27
|
+
typedef struct {
|
|
28
|
+
CGFloat r, g, b, a;
|
|
29
|
+
} RGBAComponents;
|
|
30
|
+
|
|
31
|
+
@interface PolylineAnimatorBase : NSObject {
|
|
32
|
+
@protected
|
|
33
|
+
RGBAComponents *_colorCache;
|
|
34
|
+
NSUInteger _colorCacheCount;
|
|
35
|
+
}
|
|
16
36
|
|
|
17
37
|
@property(nonatomic, strong) NSArray<CLLocation *> *coordinates;
|
|
18
38
|
@property(nonatomic, strong) NSArray<UIColor *> *strokeColors;
|
|
39
|
+
@property(nonatomic, strong) PolylineAnimatedOptions *animatedOptions;
|
|
19
40
|
|
|
20
41
|
- (UIColor *)colorAtGradientPosition:(CGFloat)position;
|
|
42
|
+
- (void)colorAtGradientPosition:(CGFloat)position rgba:(RGBAComponents *)out;
|
|
43
|
+
- (CGFloat)applyEasing:(CGFloat)t;
|
|
21
44
|
|
|
22
45
|
@end
|
|
@@ -1,35 +1,98 @@
|
|
|
1
1
|
#import "PolylineAnimatorBase.h"
|
|
2
2
|
|
|
3
|
+
@implementation PolylineAnimatedOptions
|
|
4
|
+
|
|
5
|
+
+ (instancetype)defaultOptions {
|
|
6
|
+
PolylineAnimatedOptions *options = [[PolylineAnimatedOptions alloc] init];
|
|
7
|
+
options.duration = 2.15;
|
|
8
|
+
options.easing = @"linear";
|
|
9
|
+
options.trailLength = 1.0;
|
|
10
|
+
options.delay = 0;
|
|
11
|
+
return options;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
@end
|
|
15
|
+
|
|
3
16
|
@implementation PolylineAnimatorBase
|
|
4
17
|
|
|
5
|
-
- (
|
|
6
|
-
if (
|
|
7
|
-
|
|
18
|
+
- (instancetype)init {
|
|
19
|
+
if (self = [super init]) {
|
|
20
|
+
_animatedOptions = [PolylineAnimatedOptions defaultOptions];
|
|
21
|
+
_colorCache = NULL;
|
|
22
|
+
_colorCacheCount = 0;
|
|
23
|
+
}
|
|
24
|
+
return self;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
- (void)dealloc {
|
|
28
|
+
free(_colorCache);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
- (void)setStrokeColors:(NSArray<UIColor *> *)strokeColors {
|
|
32
|
+
_strokeColors = strokeColors;
|
|
33
|
+
[self rebuildColorCache];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
- (void)rebuildColorCache {
|
|
37
|
+
free(_colorCache);
|
|
38
|
+
_colorCache = NULL;
|
|
39
|
+
_colorCacheCount = _strokeColors.count;
|
|
40
|
+
if (_colorCacheCount == 0) return;
|
|
41
|
+
|
|
42
|
+
_colorCache = (RGBAComponents *)malloc(sizeof(RGBAComponents) * _colorCacheCount);
|
|
43
|
+
for (NSUInteger i = 0; i < _colorCacheCount; i++) {
|
|
44
|
+
[_strokeColors[i] getRed:&_colorCache[i].r
|
|
45
|
+
green:&_colorCache[i].g
|
|
46
|
+
blue:&_colorCache[i].b
|
|
47
|
+
alpha:&_colorCache[i].a];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
- (CGFloat)applyEasing:(CGFloat)t {
|
|
52
|
+
NSString *easing = self.animatedOptions.easing ?: @"linear";
|
|
53
|
+
|
|
54
|
+
if ([easing isEqualToString:@"easeIn"]) {
|
|
55
|
+
return t * t;
|
|
56
|
+
} else if ([easing isEqualToString:@"easeOut"]) {
|
|
57
|
+
return t * (2 - t);
|
|
58
|
+
} else if ([easing isEqualToString:@"easeInOut"]) {
|
|
59
|
+
return t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
|
|
8
60
|
}
|
|
9
|
-
|
|
10
|
-
|
|
61
|
+
return t;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
- (void)colorAtGradientPosition:(CGFloat)position rgba:(RGBAComponents *)out {
|
|
65
|
+
if (_colorCacheCount == 0) {
|
|
66
|
+
*out = (RGBAComponents){0, 0, 0, 1};
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (_colorCacheCount == 1) {
|
|
70
|
+
*out = _colorCache[0];
|
|
71
|
+
return;
|
|
11
72
|
}
|
|
12
73
|
|
|
13
74
|
position = MAX(0, MIN(1, position));
|
|
14
|
-
CGFloat scaledPos = position * (
|
|
15
|
-
NSUInteger index = (NSUInteger)
|
|
75
|
+
CGFloat scaledPos = position * (_colorCacheCount - 1);
|
|
76
|
+
NSUInteger index = (NSUInteger)scaledPos;
|
|
16
77
|
CGFloat t = scaledPos - index;
|
|
17
78
|
|
|
18
|
-
if (index >=
|
|
19
|
-
|
|
79
|
+
if (index >= _colorCacheCount - 1) {
|
|
80
|
+
*out = _colorCache[_colorCacheCount - 1];
|
|
81
|
+
return;
|
|
20
82
|
}
|
|
21
83
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
84
|
+
RGBAComponents c1 = _colorCache[index];
|
|
85
|
+
RGBAComponents c2 = _colorCache[index + 1];
|
|
86
|
+
out->r = c1.r + (c2.r - c1.r) * t;
|
|
87
|
+
out->g = c1.g + (c2.g - c1.g) * t;
|
|
88
|
+
out->b = c1.b + (c2.b - c1.b) * t;
|
|
89
|
+
out->a = c1.a + (c2.a - c1.a) * t;
|
|
90
|
+
}
|
|
28
91
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
92
|
+
- (UIColor *)colorAtGradientPosition:(CGFloat)position {
|
|
93
|
+
RGBAComponents rgba;
|
|
94
|
+
[self colorAtGradientPosition:position rgba:&rgba];
|
|
95
|
+
return [UIColor colorWithRed:rgba.r green:rgba.g blue:rgba.b alpha:rgba.a];
|
|
33
96
|
}
|
|
34
97
|
|
|
35
98
|
@end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#import <react/renderer/components/RNMapsSpec/EventEmitters.h>
|
|
4
|
+
|
|
5
|
+
namespace luggmaps {
|
|
6
|
+
namespace events {
|
|
7
|
+
|
|
8
|
+
struct LongPressEvent {
|
|
9
|
+
double latitude;
|
|
10
|
+
double longitude;
|
|
11
|
+
double x;
|
|
12
|
+
double y;
|
|
13
|
+
|
|
14
|
+
template <typename Emitter>
|
|
15
|
+
void emit(const facebook::react::SharedEventEmitter &eventEmitter) const {
|
|
16
|
+
if (!eventEmitter)
|
|
17
|
+
return;
|
|
18
|
+
auto emitter = std::static_pointer_cast<Emitter const>(eventEmitter);
|
|
19
|
+
typename Emitter::OnMapLongPress event;
|
|
20
|
+
event.coordinate.latitude = latitude;
|
|
21
|
+
event.coordinate.longitude = longitude;
|
|
22
|
+
event.point.x = x;
|
|
23
|
+
event.point.y = y;
|
|
24
|
+
emitter->onMapLongPress(event);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
} // namespace events
|
|
29
|
+
} // namespace luggmaps
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#import <react/renderer/components/RNMapsSpec/EventEmitters.h>
|
|
4
|
+
|
|
5
|
+
namespace luggmaps {
|
|
6
|
+
namespace events {
|
|
7
|
+
|
|
8
|
+
struct MarkerDragStartEvent {
|
|
9
|
+
double latitude;
|
|
10
|
+
double longitude;
|
|
11
|
+
double x;
|
|
12
|
+
double y;
|
|
13
|
+
|
|
14
|
+
template <typename Emitter>
|
|
15
|
+
void emit(const facebook::react::SharedEventEmitter &eventEmitter) const {
|
|
16
|
+
if (!eventEmitter)
|
|
17
|
+
return;
|
|
18
|
+
auto emitter = std::static_pointer_cast<Emitter const>(eventEmitter);
|
|
19
|
+
typename Emitter::OnMarkerDragStart event;
|
|
20
|
+
event.coordinate.latitude = latitude;
|
|
21
|
+
event.coordinate.longitude = longitude;
|
|
22
|
+
event.point.x = x;
|
|
23
|
+
event.point.y = y;
|
|
24
|
+
emitter->onMarkerDragStart(event);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
struct MarkerDragChangeEvent {
|
|
29
|
+
double latitude;
|
|
30
|
+
double longitude;
|
|
31
|
+
double x;
|
|
32
|
+
double y;
|
|
33
|
+
|
|
34
|
+
template <typename Emitter>
|
|
35
|
+
void emit(const facebook::react::SharedEventEmitter &eventEmitter) const {
|
|
36
|
+
if (!eventEmitter)
|
|
37
|
+
return;
|
|
38
|
+
auto emitter = std::static_pointer_cast<Emitter const>(eventEmitter);
|
|
39
|
+
typename Emitter::OnMarkerDragChange event;
|
|
40
|
+
event.coordinate.latitude = latitude;
|
|
41
|
+
event.coordinate.longitude = longitude;
|
|
42
|
+
event.point.x = x;
|
|
43
|
+
event.point.y = y;
|
|
44
|
+
emitter->onMarkerDragChange(event);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
struct MarkerDragEndEvent {
|
|
49
|
+
double latitude;
|
|
50
|
+
double longitude;
|
|
51
|
+
double x;
|
|
52
|
+
double y;
|
|
53
|
+
|
|
54
|
+
template <typename Emitter>
|
|
55
|
+
void emit(const facebook::react::SharedEventEmitter &eventEmitter) const {
|
|
56
|
+
if (!eventEmitter)
|
|
57
|
+
return;
|
|
58
|
+
auto emitter = std::static_pointer_cast<Emitter const>(eventEmitter);
|
|
59
|
+
typename Emitter::OnMarkerDragEnd event;
|
|
60
|
+
event.coordinate.latitude = latitude;
|
|
61
|
+
event.coordinate.longitude = longitude;
|
|
62
|
+
event.point.x = x;
|
|
63
|
+
event.point.y = y;
|
|
64
|
+
emitter->onMarkerDragEnd(event);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
} // namespace events
|
|
69
|
+
} // namespace luggmaps
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#import <react/renderer/components/RNMapsSpec/EventEmitters.h>
|
|
4
|
+
|
|
5
|
+
namespace luggmaps {
|
|
6
|
+
namespace events {
|
|
7
|
+
|
|
8
|
+
struct MarkerPressEvent {
|
|
9
|
+
double latitude;
|
|
10
|
+
double longitude;
|
|
11
|
+
double x;
|
|
12
|
+
double y;
|
|
13
|
+
|
|
14
|
+
template <typename Emitter>
|
|
15
|
+
void emit(const facebook::react::SharedEventEmitter &eventEmitter) const {
|
|
16
|
+
if (!eventEmitter)
|
|
17
|
+
return;
|
|
18
|
+
auto emitter = std::static_pointer_cast<Emitter const>(eventEmitter);
|
|
19
|
+
typename Emitter::OnMarkerPress event;
|
|
20
|
+
event.coordinate.latitude = latitude;
|
|
21
|
+
event.coordinate.longitude = longitude;
|
|
22
|
+
event.point.x = x;
|
|
23
|
+
event.point.y = y;
|
|
24
|
+
emitter->onMarkerPress(event);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
} // namespace events
|
|
29
|
+
} // namespace luggmaps
|