@lugg/maps 0.2.0-alpha.3 → 0.2.0-alpha.30
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 -3
- package/android/src/main/java/com/luggmaps/LuggMapView.kt +265 -0
- package/android/src/main/java/com/luggmaps/{LuggGoogleMapViewManager.kt → LuggMapViewManager.kt} +75 -36
- package/android/src/main/java/com/luggmaps/LuggMapWrapperView.kt +6 -5
- package/android/src/main/java/com/luggmaps/LuggMarkerView.kt +136 -14
- package/android/src/main/java/com/luggmaps/LuggMarkerViewManager.kt +21 -0
- package/android/src/main/java/com/luggmaps/LuggPackage.kt +1 -4
- 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/{LuggGoogleMapView.kt → core/GoogleMapProvider.kt} +251 -241
- package/android/src/main/java/com/luggmaps/core/MapProviderDelegate.kt +55 -0
- package/android/src/main/java/com/luggmaps/core/PolylineAnimator.kt +163 -52
- package/ios/LuggMapView.h +9 -0
- package/ios/LuggMapView.mm +312 -0
- package/ios/LuggMarkerView.h +9 -0
- package/ios/LuggMarkerView.mm +79 -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 +664 -0
- package/ios/core/GMSPolylineAnimator.h +3 -0
- package/ios/core/GMSPolylineAnimator.m +175 -40
- package/ios/core/GoogleMapProvider.h +13 -0
- package/ios/core/GoogleMapProvider.mm +513 -0
- package/ios/core/MKPolylineAnimator.h +4 -0
- package/ios/core/MKPolylineAnimator.m +224 -68
- package/ios/core/MapProviderDelegate.h +72 -0
- package/ios/core/PolylineAnimatorBase.h +24 -1
- package/ios/core/PolylineAnimatorBase.m +82 -19
- package/ios/extensions/MKMapView+Zoom.h +2 -0
- package/ios/extensions/MKMapView+Zoom.m +14 -4
- package/lib/module/MapProvider.js +13 -0
- package/lib/module/MapProvider.js.map +1 -0
- package/lib/module/MapProvider.types.js +4 -0
- package/lib/module/MapProvider.types.js.map +1 -0
- package/lib/module/MapProvider.web.js +20 -0
- package/lib/module/MapProvider.web.js.map +1 -0
- package/lib/module/MapView.js +29 -16
- package/lib/module/MapView.js.map +1 -1
- package/lib/module/MapView.web.js +290 -0
- package/lib/module/MapView.web.js.map +1 -0
- package/lib/module/components/Marker.js +19 -2
- package/lib/module/components/Marker.js.map +1 -1
- package/lib/module/components/Marker.web.js +33 -0
- package/lib/module/components/Marker.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.web.js +229 -0
- package/lib/module/components/Polyline.web.js.map +1 -0
- package/lib/module/components/index.js +2 -2
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/components/index.web.js +5 -0
- package/lib/module/components/index.web.js.map +1 -0
- package/lib/module/fabric/{LuggGoogleMapViewNativeComponent.ts → LuggMapViewNativeComponent.ts} +19 -7
- package/lib/module/fabric/LuggMarkerViewNativeComponent.ts +7 -1
- package/lib/module/fabric/LuggPolylineViewNativeComponent.ts +8 -0
- package/lib/module/index.js +4 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js +7 -0
- package/lib/module/index.web.js.map +1 -0
- package/lib/typescript/src/MapProvider.d.ts +8 -0
- package/lib/typescript/src/MapProvider.d.ts.map +1 -0
- package/lib/typescript/src/MapProvider.types.d.ts +16 -0
- package/lib/typescript/src/MapProvider.types.d.ts.map +1 -0
- package/lib/typescript/src/MapProvider.web.d.ts +11 -0
- package/lib/typescript/src/MapProvider.web.d.ts.map +1 -0
- 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 +23 -7
- package/lib/typescript/src/MapView.types.d.ts.map +1 -1
- package/lib/typescript/src/MapView.web.d.ts +3 -0
- package/lib/typescript/src/MapView.web.d.ts.map +1 -0
- package/lib/typescript/src/components/Marker.d.ts +25 -1
- package/lib/typescript/src/components/Marker.d.ts.map +1 -1
- package/lib/typescript/src/components/Marker.web.d.ts +3 -0
- package/lib/typescript/src/components/Marker.web.d.ts.map +1 -0
- package/lib/typescript/src/components/Polyline.d.ts +36 -1
- package/lib/typescript/src/components/Polyline.d.ts.map +1 -1
- package/lib/typescript/src/components/Polyline.web.d.ts +3 -0
- package/lib/typescript/src/components/Polyline.web.d.ts.map +1 -0
- package/lib/typescript/src/components/index.d.ts +4 -2
- package/lib/typescript/src/components/index.d.ts.map +1 -1
- package/lib/typescript/src/components/index.web.d.ts +5 -0
- package/lib/typescript/src/components/index.web.d.ts.map +1 -0
- package/lib/typescript/src/fabric/{LuggGoogleMapViewNativeComponent.d.ts → LuggMapViewNativeComponent.d.ts} +8 -4
- package/lib/typescript/src/fabric/LuggMapViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/fabric/LuggMarkerViewNativeComponent.d.ts +4 -1
- package/lib/typescript/src/fabric/LuggMarkerViewNativeComponent.d.ts.map +1 -1
- 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 +8 -3
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/index.web.d.ts +10 -0
- package/lib/typescript/src/index.web.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +4 -0
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/package.json +17 -3
- package/src/MapProvider.tsx +10 -0
- package/src/MapProvider.types.ts +16 -0
- package/src/MapProvider.web.tsx +14 -0
- package/src/MapView.tsx +28 -26
- package/src/MapView.types.ts +24 -7
- package/src/MapView.web.tsx +364 -0
- package/src/components/Marker.tsx +50 -4
- package/src/components/Marker.web.tsx +33 -0
- package/src/components/Polyline.tsx +51 -2
- package/src/components/Polyline.web.tsx +287 -0
- package/src/components/index.ts +8 -2
- package/src/components/index.web.ts +4 -0
- package/src/fabric/{LuggGoogleMapViewNativeComponent.ts → LuggMapViewNativeComponent.ts} +19 -7
- package/src/fabric/LuggMarkerViewNativeComponent.ts +7 -1
- package/src/fabric/LuggPolylineViewNativeComponent.ts +8 -0
- package/src/index.ts +18 -2
- package/src/index.web.ts +20 -0
- package/src/types.ts +5 -0
- package/ios/LuggAppleMapView.h +0 -16
- package/ios/LuggAppleMapView.mm +0 -580
- package/ios/LuggGoogleMapView.h +0 -13
- package/ios/LuggGoogleMapView.mm +0 -454
- 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
package/ios/LuggMarkerView.mm
CHANGED
|
@@ -13,10 +13,15 @@ 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;
|
|
22
|
+
CLLocationDegrees _rotate;
|
|
23
|
+
CGFloat _scale;
|
|
24
|
+
BOOL _rasterize;
|
|
20
25
|
BOOL _didLayout;
|
|
21
26
|
UIView *_iconView;
|
|
22
27
|
}
|
|
@@ -34,6 +39,10 @@ using namespace facebook::react;
|
|
|
34
39
|
|
|
35
40
|
_coordinate = CLLocationCoordinate2DMake(0, 0);
|
|
36
41
|
_anchor = CGPointMake(0.5, 1.0);
|
|
42
|
+
_zIndex = 0;
|
|
43
|
+
_rotate = 0;
|
|
44
|
+
_scale = 1;
|
|
45
|
+
_rasterize = YES;
|
|
37
46
|
_didLayout = NO;
|
|
38
47
|
|
|
39
48
|
_iconView = [[UIView alloc] init];
|
|
@@ -52,12 +61,17 @@ using namespace facebook::react;
|
|
|
52
61
|
const auto &newViewProps =
|
|
53
62
|
*std::static_pointer_cast<LuggMarkerViewProps const>(props);
|
|
54
63
|
|
|
64
|
+
_name = [NSString stringWithUTF8String:newViewProps.name.c_str()];
|
|
55
65
|
_coordinate = CLLocationCoordinate2DMake(newViewProps.coordinate.latitude,
|
|
56
66
|
newViewProps.coordinate.longitude);
|
|
57
67
|
_title = [NSString stringWithUTF8String:newViewProps.title.c_str()];
|
|
58
68
|
_markerDescription =
|
|
59
69
|
[NSString stringWithUTF8String:newViewProps.description.c_str()];
|
|
60
70
|
_anchor = CGPointMake(newViewProps.anchor.x, newViewProps.anchor.y);
|
|
71
|
+
_zIndex = newViewProps.zIndex.value_or(0);
|
|
72
|
+
_rotate = newViewProps.rotate;
|
|
73
|
+
_scale = newViewProps.scale;
|
|
74
|
+
_rasterize = newViewProps.rasterize;
|
|
61
75
|
}
|
|
62
76
|
|
|
63
77
|
- (void)finalizeUpdates:(RNComponentViewUpdateMask)updateMask {
|
|
@@ -109,6 +123,10 @@ using namespace facebook::react;
|
|
|
109
123
|
}
|
|
110
124
|
}
|
|
111
125
|
|
|
126
|
+
- (NSString *)name {
|
|
127
|
+
return _name;
|
|
128
|
+
}
|
|
129
|
+
|
|
112
130
|
- (CLLocationCoordinate2D)coordinate {
|
|
113
131
|
return _coordinate;
|
|
114
132
|
}
|
|
@@ -125,6 +143,22 @@ using namespace facebook::react;
|
|
|
125
143
|
return _anchor;
|
|
126
144
|
}
|
|
127
145
|
|
|
146
|
+
- (NSInteger)zIndex {
|
|
147
|
+
return _zIndex;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
- (CLLocationDegrees)rotate {
|
|
151
|
+
return _rotate;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
- (CGFloat)scale {
|
|
155
|
+
return _scale;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
- (BOOL)rasterize {
|
|
159
|
+
return _rasterize;
|
|
160
|
+
}
|
|
161
|
+
|
|
128
162
|
- (BOOL)hasCustomView {
|
|
129
163
|
return _iconView.subviews.count > 0;
|
|
130
164
|
}
|
|
@@ -137,11 +171,56 @@ using namespace facebook::react;
|
|
|
137
171
|
return _iconView;
|
|
138
172
|
}
|
|
139
173
|
|
|
174
|
+
- (UIImage *)createIconImage {
|
|
175
|
+
CGSize size = _iconView.bounds.size;
|
|
176
|
+
if (size.width <= 0 || size.height <= 0) {
|
|
177
|
+
return nil;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
UIGraphicsImageRendererFormat *format =
|
|
181
|
+
[UIGraphicsImageRendererFormat defaultFormat];
|
|
182
|
+
format.scale = [UIScreen mainScreen].scale;
|
|
183
|
+
UIGraphicsImageRenderer *renderer =
|
|
184
|
+
[[UIGraphicsImageRenderer alloc] initWithSize:size format:format];
|
|
185
|
+
|
|
186
|
+
return [renderer imageWithActions:^(UIGraphicsImageRendererContext *context) {
|
|
187
|
+
[self->_iconView.layer renderInContext:context.CGContext];
|
|
188
|
+
}];
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
- (UIImage *)createScaledIconImage {
|
|
192
|
+
CGSize size = _iconView.bounds.size;
|
|
193
|
+
if (size.width <= 0 || size.height <= 0) {
|
|
194
|
+
return nil;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
CGSize scaledSize = CGSizeMake(size.width * _scale, size.height * _scale);
|
|
198
|
+
|
|
199
|
+
UIGraphicsImageRendererFormat *format =
|
|
200
|
+
[UIGraphicsImageRendererFormat defaultFormat];
|
|
201
|
+
format.scale = [UIScreen mainScreen].scale;
|
|
202
|
+
UIGraphicsImageRenderer *renderer =
|
|
203
|
+
[[UIGraphicsImageRenderer alloc] initWithSize:scaledSize format:format];
|
|
204
|
+
|
|
205
|
+
return [renderer imageWithActions:^(UIGraphicsImageRendererContext *context) {
|
|
206
|
+
CGContextScaleCTM(context.CGContext, self->_scale, self->_scale);
|
|
207
|
+
[self->_iconView.layer renderInContext:context.CGContext];
|
|
208
|
+
}];
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
- (void)resetIconViewTransform {
|
|
212
|
+
_iconView.transform = CGAffineTransformIdentity;
|
|
213
|
+
_iconView.layer.anchorPoint = CGPointMake(0.5, 0.5);
|
|
214
|
+
_iconView.frame = CGRectMake(0, 0, _iconView.bounds.size.width,
|
|
215
|
+
_iconView.bounds.size.height);
|
|
216
|
+
}
|
|
217
|
+
|
|
140
218
|
- (void)prepareForRecycle {
|
|
141
219
|
[super prepareForRecycle];
|
|
142
220
|
_didLayout = NO;
|
|
143
221
|
self.marker = nil;
|
|
144
222
|
self.delegate = nil;
|
|
223
|
+
[self resetIconViewTransform];
|
|
145
224
|
for (UIView *subview in _iconView.subviews) {
|
|
146
225
|
[subview removeFromSuperview];
|
|
147
226
|
}
|
package/ios/LuggPolylineView.h
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#import "core/PolylineAnimatorBase.h"
|
|
1
2
|
#import <CoreLocation/CoreLocation.h>
|
|
2
3
|
#import <React/RCTViewComponentView.h>
|
|
3
4
|
#import <UIKit/UIKit.h>
|
|
@@ -16,7 +17,10 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
16
17
|
@property(nonatomic, readonly) NSArray<CLLocation *> *coordinates;
|
|
17
18
|
@property(nonatomic, readonly) NSArray<UIColor *> *strokeColors;
|
|
18
19
|
@property(nonatomic, readonly) BOOL animated;
|
|
20
|
+
@property(nonatomic, readonly, nullable)
|
|
21
|
+
PolylineAnimatedOptions *animatedOptions;
|
|
19
22
|
@property(nonatomic, readonly) CGFloat strokeWidth;
|
|
23
|
+
@property(nonatomic, readonly) NSInteger zIndex;
|
|
20
24
|
@property(nonatomic, weak, nullable) id<LuggPolylineViewDelegate> delegate;
|
|
21
25
|
@property(nonatomic, strong, nullable) NSObject *polyline;
|
|
22
26
|
@property(nonatomic, weak, nullable) NSObject *renderer;
|
package/ios/LuggPolylineView.mm
CHANGED
|
@@ -17,7 +17,9 @@ using namespace facebook::react;
|
|
|
17
17
|
NSArray<CLLocation *> *_coordinates;
|
|
18
18
|
NSArray<UIColor *> *_strokeColors;
|
|
19
19
|
BOOL _animated;
|
|
20
|
+
PolylineAnimatedOptions *_animatedOptions;
|
|
20
21
|
CGFloat _strokeWidth;
|
|
22
|
+
NSInteger _zIndex;
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
+ (ComponentDescriptorProvider)componentDescriptorProvider {
|
|
@@ -72,7 +74,20 @@ using namespace facebook::react;
|
|
|
72
74
|
|
|
73
75
|
_animated = newViewProps.animated;
|
|
74
76
|
|
|
77
|
+
const auto &opts = newViewProps.animatedOptions;
|
|
78
|
+
PolylineAnimatedOptions *options = [[PolylineAnimatedOptions alloc] init];
|
|
79
|
+
options.duration = opts.duration > 0 ? opts.duration : 2150;
|
|
80
|
+
options.trailLength = (opts.trailLength > 0 && opts.trailLength <= 1.0)
|
|
81
|
+
? opts.trailLength
|
|
82
|
+
: 1.0;
|
|
83
|
+
options.delay = opts.delay;
|
|
84
|
+
options.easing = !opts.easing.empty()
|
|
85
|
+
? [NSString stringWithUTF8String:opts.easing.c_str()]
|
|
86
|
+
: @"linear";
|
|
87
|
+
_animatedOptions = options;
|
|
88
|
+
|
|
75
89
|
_strokeWidth = newViewProps.strokeWidth > 0 ? newViewProps.strokeWidth : 1.0;
|
|
90
|
+
_zIndex = newViewProps.zIndex.value_or(0);
|
|
76
91
|
}
|
|
77
92
|
|
|
78
93
|
- (void)finalizeUpdates:(RNComponentViewUpdateMask)updateMask {
|
|
@@ -97,10 +112,18 @@ using namespace facebook::react;
|
|
|
97
112
|
return _animated;
|
|
98
113
|
}
|
|
99
114
|
|
|
115
|
+
- (PolylineAnimatedOptions *)animatedOptions {
|
|
116
|
+
return _animatedOptions;
|
|
117
|
+
}
|
|
118
|
+
|
|
100
119
|
- (CGFloat)strokeWidth {
|
|
101
120
|
return _strokeWidth;
|
|
102
121
|
}
|
|
103
122
|
|
|
123
|
+
- (NSInteger)zIndex {
|
|
124
|
+
return _zIndex;
|
|
125
|
+
}
|
|
126
|
+
|
|
104
127
|
- (void)prepareForRecycle {
|
|
105
128
|
[super prepareForRecycle];
|
|
106
129
|
self.polyline = nil;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#import "MapProviderDelegate.h"
|
|
2
|
+
#import <MapKit/MapKit.h>
|
|
3
|
+
|
|
4
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
5
|
+
|
|
6
|
+
@interface LuggAppleMapViewContent : MKMapView
|
|
7
|
+
@end
|
|
8
|
+
|
|
9
|
+
@interface AppleMapProvider : NSObject <MapProvider, MKMapViewDelegate>
|
|
10
|
+
|
|
11
|
+
@property(nonatomic, readonly, nullable) MKMapView *mapView;
|
|
12
|
+
|
|
13
|
+
@end
|
|
14
|
+
|
|
15
|
+
NS_ASSUME_NONNULL_END
|