@lugg/maps 0.2.0-alpha.9 → 1.0.0-beta.1
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 +21 -20
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/luggmaps/LuggCalloutView.kt +74 -0
- package/android/src/main/java/com/luggmaps/LuggCalloutViewManager.kt +38 -0
- 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 +11 -14
- package/android/src/main/java/com/luggmaps/LuggMarkerView.kt +187 -21
- package/android/src/main/java/com/luggmaps/LuggMarkerViewManager.kt +28 -0
- package/android/src/main/java/com/luggmaps/LuggPackage.kt +8 -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 +874 -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/LuggCalloutView.h +23 -0
- package/ios/LuggCalloutView.mm +145 -0
- package/ios/LuggMapView.h +9 -0
- package/ios/LuggMapView.mm +343 -0
- package/ios/LuggMarkerView.h +15 -0
- package/ios/LuggMarkerView.mm +136 -2
- 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 +1173 -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 +798 -0
- package/ios/core/LuggAnnotationView.h +12 -0
- package/ios/core/LuggAnnotationView.mm +55 -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 +14 -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 +296 -181
- 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 +49 -8
- 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 +159 -24
- 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/LuggCalloutViewNativeComponent.ts +20 -0
- 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 +23 -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 +89 -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 +100 -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/LuggCalloutViewNativeComponent.d.ts +13 -0
- package/lib/typescript/src/fabric/LuggCalloutViewNativeComponent.d.ts.map +1 -0
- 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 +11 -9
- package/src/MapProvider.tsx +1 -3
- package/src/MapProvider.web.tsx +22 -3
- package/src/MapView.tsx +32 -26
- package/src/MapView.types.ts +43 -9
- package/src/MapView.web.tsx +368 -210
- package/src/components/GeoJson.tsx +221 -0
- package/src/components/GeoJson.types.ts +118 -0
- package/src/components/Marker.tsx +75 -38
- package/src/components/Marker.types.ts +102 -0
- package/src/components/Marker.web.tsx +197 -19
- 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 +17 -2
- package/src/components/index.web.ts +6 -2
- package/src/fabric/LuggCalloutViewNativeComponent.ts +20 -0
- 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 +30 -1
- package/src/index.web.ts +16 -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,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
|
-
|
|
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
|
-
|
|
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 >=
|
|
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
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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
|
-
|
|
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
|
|
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 (
|
|
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 =
|
|
216
|
+
headDist = easedProgress * _totalLength;
|
|
141
217
|
} else {
|
|
142
|
-
CGFloat shrinkProgress =
|
|
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
|
-
|
|
175
|
-
|
|
176
|
-
|
|
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
|