@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.
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 +315 -217
  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 +376 -244
  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
@@ -0,0 +1,151 @@
1
+ #import "LuggPolygonView.h"
2
+ #import "events/PolygonPressEvent.h"
3
+
4
+ #import <react/renderer/components/RNMapsSpec/ComponentDescriptors.h>
5
+ #import <react/renderer/components/RNMapsSpec/EventEmitters.h>
6
+ #import <react/renderer/components/RNMapsSpec/Props.h>
7
+ #import <react/renderer/components/RNMapsSpec/RCTComponentViewHelpers.h>
8
+
9
+ #import "RCTFabricComponentsPlugins.h"
10
+ #import <React/RCTConversions.h>
11
+
12
+ using namespace facebook::react;
13
+ using namespace luggmaps::events;
14
+
15
+ @interface LuggPolygonView () <RCTLuggPolygonViewViewProtocol>
16
+ @end
17
+
18
+ @implementation LuggPolygonView {
19
+ NSArray<CLLocation *> *_coordinates;
20
+ NSArray<NSArray<CLLocation *> *> *_holes;
21
+ UIColor *_strokeColor;
22
+ UIColor *_fillColor;
23
+ CGFloat _strokeWidth;
24
+ NSInteger _zIndex;
25
+ BOOL _tappable;
26
+ }
27
+
28
+ + (ComponentDescriptorProvider)componentDescriptorProvider {
29
+ return concreteComponentDescriptorProvider<
30
+ LuggPolygonViewComponentDescriptor>();
31
+ }
32
+
33
+ - (instancetype)initWithFrame:(CGRect)frame {
34
+ if (self = [super initWithFrame:frame]) {
35
+ static const auto defaultProps =
36
+ std::make_shared<const LuggPolygonViewProps>();
37
+ _props = defaultProps;
38
+
39
+ _coordinates = @[];
40
+ _holes = @[];
41
+ _strokeColor = [UIColor blackColor];
42
+ _fillColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.3];
43
+ _strokeWidth = 1.0;
44
+
45
+ self.hidden = YES;
46
+ }
47
+
48
+ return self;
49
+ }
50
+
51
+ - (void)updateProps:(Props::Shared const &)props
52
+ oldProps:(Props::Shared const &)oldProps {
53
+ [super updateProps:props oldProps:oldProps];
54
+ const auto &newViewProps =
55
+ *std::static_pointer_cast<LuggPolygonViewProps const>(props);
56
+
57
+ NSMutableArray<CLLocation *> *coords = [NSMutableArray array];
58
+ for (const auto &coord : newViewProps.coordinates) {
59
+ CLLocation *location =
60
+ [[CLLocation alloc] initWithLatitude:coord.latitude
61
+ longitude:coord.longitude];
62
+ [coords addObject:location];
63
+ }
64
+ _coordinates = [coords copy];
65
+
66
+ NSMutableArray<NSArray<CLLocation *> *> *holesArray = [NSMutableArray array];
67
+ for (const auto &hole : newViewProps.holes) {
68
+ NSMutableArray<CLLocation *> *holeCoords = [NSMutableArray array];
69
+ for (const auto &coord : hole) {
70
+ CLLocation *location =
71
+ [[CLLocation alloc] initWithLatitude:coord.latitude
72
+ longitude:coord.longitude];
73
+ [holeCoords addObject:location];
74
+ }
75
+ [holesArray addObject:[holeCoords copy]];
76
+ }
77
+ _holes = [holesArray copy];
78
+
79
+ if (newViewProps.strokeColor) {
80
+ UIColor *color = RCTUIColorFromSharedColor(newViewProps.strokeColor);
81
+ if (color) {
82
+ _strokeColor = color;
83
+ }
84
+ }
85
+
86
+ if (newViewProps.fillColor) {
87
+ UIColor *color = RCTUIColorFromSharedColor(newViewProps.fillColor);
88
+ if (color) {
89
+ _fillColor = color;
90
+ }
91
+ }
92
+
93
+ _strokeWidth = newViewProps.strokeWidth > 0 ? newViewProps.strokeWidth : 1.0;
94
+ _zIndex = newViewProps.zIndex.value_or(0);
95
+ _tappable = newViewProps.tappable;
96
+ }
97
+
98
+ - (void)finalizeUpdates:(RNComponentViewUpdateMask)updateMask {
99
+ [super finalizeUpdates:updateMask];
100
+
101
+ if (updateMask & RNComponentViewUpdateMaskProps) {
102
+ if ([self.delegate respondsToSelector:@selector(polygonViewDidUpdate:)]) {
103
+ [self.delegate polygonViewDidUpdate:self];
104
+ }
105
+ }
106
+ }
107
+
108
+ - (NSArray<CLLocation *> *)coordinates {
109
+ return _coordinates;
110
+ }
111
+
112
+ - (NSArray<NSArray<CLLocation *> *> *)holes {
113
+ return _holes;
114
+ }
115
+
116
+ - (UIColor *)strokeColor {
117
+ return _strokeColor;
118
+ }
119
+
120
+ - (UIColor *)fillColor {
121
+ return _fillColor;
122
+ }
123
+
124
+ - (CGFloat)strokeWidth {
125
+ return _strokeWidth;
126
+ }
127
+
128
+ - (NSInteger)zIndex {
129
+ return _zIndex;
130
+ }
131
+
132
+ - (BOOL)tappable {
133
+ return _tappable;
134
+ }
135
+
136
+ - (void)emitPressEvent {
137
+ PolygonPressEvent::emit<LuggPolygonViewEventEmitter>(_eventEmitter);
138
+ }
139
+
140
+ - (void)prepareForRecycle {
141
+ [super prepareForRecycle];
142
+ self.polygon = nil;
143
+ self.renderer = nil;
144
+ self.delegate = nil;
145
+ }
146
+
147
+ Class<RCTComponentViewProtocol> LuggPolygonViewCls(void) {
148
+ return LuggPolygonView.class;
149
+ }
150
+
151
+ @end
@@ -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