@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.
Files changed (124) hide show
  1. package/README.md +21 -3
  2. package/android/src/main/java/com/luggmaps/LuggMapView.kt +265 -0
  3. package/android/src/main/java/com/luggmaps/{LuggGoogleMapViewManager.kt → LuggMapViewManager.kt} +75 -36
  4. package/android/src/main/java/com/luggmaps/LuggMapWrapperView.kt +6 -5
  5. package/android/src/main/java/com/luggmaps/LuggMarkerView.kt +136 -14
  6. package/android/src/main/java/com/luggmaps/LuggMarkerViewManager.kt +21 -0
  7. package/android/src/main/java/com/luggmaps/LuggPackage.kt +1 -4
  8. package/android/src/main/java/com/luggmaps/LuggPolylineView.kt +16 -0
  9. package/android/src/main/java/com/luggmaps/LuggPolylineViewManager.kt +22 -0
  10. package/android/src/main/java/com/luggmaps/{LuggGoogleMapView.kt → core/GoogleMapProvider.kt} +251 -241
  11. package/android/src/main/java/com/luggmaps/core/MapProviderDelegate.kt +55 -0
  12. package/android/src/main/java/com/luggmaps/core/PolylineAnimator.kt +163 -52
  13. package/ios/LuggMapView.h +9 -0
  14. package/ios/LuggMapView.mm +312 -0
  15. package/ios/LuggMarkerView.h +9 -0
  16. package/ios/LuggMarkerView.mm +79 -0
  17. package/ios/LuggPolylineView.h +4 -0
  18. package/ios/LuggPolylineView.mm +23 -0
  19. package/ios/core/AppleMapProvider.h +15 -0
  20. package/ios/core/AppleMapProvider.mm +664 -0
  21. package/ios/core/GMSPolylineAnimator.h +3 -0
  22. package/ios/core/GMSPolylineAnimator.m +175 -40
  23. package/ios/core/GoogleMapProvider.h +13 -0
  24. package/ios/core/GoogleMapProvider.mm +513 -0
  25. package/ios/core/MKPolylineAnimator.h +4 -0
  26. package/ios/core/MKPolylineAnimator.m +224 -68
  27. package/ios/core/MapProviderDelegate.h +72 -0
  28. package/ios/core/PolylineAnimatorBase.h +24 -1
  29. package/ios/core/PolylineAnimatorBase.m +82 -19
  30. package/ios/extensions/MKMapView+Zoom.h +2 -0
  31. package/ios/extensions/MKMapView+Zoom.m +14 -4
  32. package/lib/module/MapProvider.js +13 -0
  33. package/lib/module/MapProvider.js.map +1 -0
  34. package/lib/module/MapProvider.types.js +4 -0
  35. package/lib/module/MapProvider.types.js.map +1 -0
  36. package/lib/module/MapProvider.web.js +20 -0
  37. package/lib/module/MapProvider.web.js.map +1 -0
  38. package/lib/module/MapView.js +29 -16
  39. package/lib/module/MapView.js.map +1 -1
  40. package/lib/module/MapView.web.js +290 -0
  41. package/lib/module/MapView.web.js.map +1 -0
  42. package/lib/module/components/Marker.js +19 -2
  43. package/lib/module/components/Marker.js.map +1 -1
  44. package/lib/module/components/Marker.web.js +33 -0
  45. package/lib/module/components/Marker.web.js.map +1 -0
  46. package/lib/module/components/Polyline.js +17 -4
  47. package/lib/module/components/Polyline.js.map +1 -1
  48. package/lib/module/components/Polyline.web.js +229 -0
  49. package/lib/module/components/Polyline.web.js.map +1 -0
  50. package/lib/module/components/index.js +2 -2
  51. package/lib/module/components/index.js.map +1 -1
  52. package/lib/module/components/index.web.js +5 -0
  53. package/lib/module/components/index.web.js.map +1 -0
  54. package/lib/module/fabric/{LuggGoogleMapViewNativeComponent.ts → LuggMapViewNativeComponent.ts} +19 -7
  55. package/lib/module/fabric/LuggMarkerViewNativeComponent.ts +7 -1
  56. package/lib/module/fabric/LuggPolylineViewNativeComponent.ts +8 -0
  57. package/lib/module/index.js +4 -2
  58. package/lib/module/index.js.map +1 -1
  59. package/lib/module/index.web.js +7 -0
  60. package/lib/module/index.web.js.map +1 -0
  61. package/lib/typescript/src/MapProvider.d.ts +8 -0
  62. package/lib/typescript/src/MapProvider.d.ts.map +1 -0
  63. package/lib/typescript/src/MapProvider.types.d.ts +16 -0
  64. package/lib/typescript/src/MapProvider.types.d.ts.map +1 -0
  65. package/lib/typescript/src/MapProvider.web.d.ts +11 -0
  66. package/lib/typescript/src/MapProvider.web.d.ts.map +1 -0
  67. package/lib/typescript/src/MapView.d.ts +4 -4
  68. package/lib/typescript/src/MapView.d.ts.map +1 -1
  69. package/lib/typescript/src/MapView.types.d.ts +23 -7
  70. package/lib/typescript/src/MapView.types.d.ts.map +1 -1
  71. package/lib/typescript/src/MapView.web.d.ts +3 -0
  72. package/lib/typescript/src/MapView.web.d.ts.map +1 -0
  73. package/lib/typescript/src/components/Marker.d.ts +25 -1
  74. package/lib/typescript/src/components/Marker.d.ts.map +1 -1
  75. package/lib/typescript/src/components/Marker.web.d.ts +3 -0
  76. package/lib/typescript/src/components/Marker.web.d.ts.map +1 -0
  77. package/lib/typescript/src/components/Polyline.d.ts +36 -1
  78. package/lib/typescript/src/components/Polyline.d.ts.map +1 -1
  79. package/lib/typescript/src/components/Polyline.web.d.ts +3 -0
  80. package/lib/typescript/src/components/Polyline.web.d.ts.map +1 -0
  81. package/lib/typescript/src/components/index.d.ts +4 -2
  82. package/lib/typescript/src/components/index.d.ts.map +1 -1
  83. package/lib/typescript/src/components/index.web.d.ts +5 -0
  84. package/lib/typescript/src/components/index.web.d.ts.map +1 -0
  85. package/lib/typescript/src/fabric/{LuggGoogleMapViewNativeComponent.d.ts → LuggMapViewNativeComponent.d.ts} +8 -4
  86. package/lib/typescript/src/fabric/LuggMapViewNativeComponent.d.ts.map +1 -0
  87. package/lib/typescript/src/fabric/LuggMarkerViewNativeComponent.d.ts +4 -1
  88. package/lib/typescript/src/fabric/LuggMarkerViewNativeComponent.d.ts.map +1 -1
  89. package/lib/typescript/src/fabric/LuggPolylineViewNativeComponent.d.ts +7 -0
  90. package/lib/typescript/src/fabric/LuggPolylineViewNativeComponent.d.ts.map +1 -1
  91. package/lib/typescript/src/index.d.ts +8 -3
  92. package/lib/typescript/src/index.d.ts.map +1 -1
  93. package/lib/typescript/src/index.web.d.ts +10 -0
  94. package/lib/typescript/src/index.web.d.ts.map +1 -0
  95. package/lib/typescript/src/types.d.ts +4 -0
  96. package/lib/typescript/src/types.d.ts.map +1 -1
  97. package/package.json +17 -3
  98. package/src/MapProvider.tsx +10 -0
  99. package/src/MapProvider.types.ts +16 -0
  100. package/src/MapProvider.web.tsx +14 -0
  101. package/src/MapView.tsx +28 -26
  102. package/src/MapView.types.ts +24 -7
  103. package/src/MapView.web.tsx +364 -0
  104. package/src/components/Marker.tsx +50 -4
  105. package/src/components/Marker.web.tsx +33 -0
  106. package/src/components/Polyline.tsx +51 -2
  107. package/src/components/Polyline.web.tsx +287 -0
  108. package/src/components/index.ts +8 -2
  109. package/src/components/index.web.ts +4 -0
  110. package/src/fabric/{LuggGoogleMapViewNativeComponent.ts → LuggMapViewNativeComponent.ts} +19 -7
  111. package/src/fabric/LuggMarkerViewNativeComponent.ts +7 -1
  112. package/src/fabric/LuggPolylineViewNativeComponent.ts +8 -0
  113. package/src/index.ts +18 -2
  114. package/src/index.web.ts +20 -0
  115. package/src/types.ts +5 -0
  116. package/ios/LuggAppleMapView.h +0 -16
  117. package/ios/LuggAppleMapView.mm +0 -580
  118. package/ios/LuggGoogleMapView.h +0 -13
  119. package/ios/LuggGoogleMapView.mm +0 -454
  120. package/lib/module/fabric/LuggAppleMapViewNativeComponent.ts +0 -83
  121. package/lib/typescript/src/fabric/LuggAppleMapViewNativeComponent.d.ts +0 -54
  122. package/lib/typescript/src/fabric/LuggAppleMapViewNativeComponent.d.ts.map +0 -1
  123. package/lib/typescript/src/fabric/LuggGoogleMapViewNativeComponent.d.ts.map +0 -1
  124. package/src/fabric/LuggAppleMapViewNativeComponent.ts +0 -83
@@ -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
  }
@@ -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;
@@ -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