@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
@@ -1,455 +0,0 @@
1
- #import "LuggGoogleMapView.h"
2
- #import "LuggMarkerView.h"
3
- #import "LuggPolylineView.h"
4
- #import "core/GMSPolylineAnimator.h"
5
- #import "core/PolylineAnimatorBase.h"
6
- #import "events/CameraIdleEvent.h"
7
- #import "events/CameraMoveEvent.h"
8
- #import "events/ReadyEvent.h"
9
-
10
- #import <react/renderer/components/RNMapsSpec/ComponentDescriptors.h>
11
- #import <react/renderer/components/RNMapsSpec/EventEmitters.h>
12
- #import <react/renderer/components/RNMapsSpec/Props.h>
13
- #import <react/renderer/components/RNMapsSpec/RCTComponentViewHelpers.h>
14
-
15
- #import "RCTFabricComponentsPlugins.h"
16
-
17
- using namespace facebook::react;
18
- using namespace luggmaps::events;
19
-
20
- #import "LuggMapWrapperView.h"
21
-
22
- static NSString *const kDemoMapId = @"DEMO_MAP_ID";
23
-
24
- @interface LuggGoogleMapView () <RCTLuggGoogleMapViewViewProtocol,
25
- GMSMapViewDelegate, LuggMarkerViewDelegate,
26
- LuggPolylineViewDelegate>
27
- @end
28
-
29
- @implementation LuggGoogleMapView {
30
- GMSMapView *_mapView;
31
- LuggMapWrapperView *_mapWrapperView;
32
- BOOL _isMapReady;
33
- BOOL _isDragging;
34
- NSString *_mapId;
35
- NSMutableArray<LuggMarkerView *> *_pendingMarkerViews;
36
- NSMutableArray<LuggPolylineView *> *_pendingPolylineViews;
37
- NSMapTable<LuggPolylineView *, GMSPolylineAnimator *> *_polylineAnimators;
38
- }
39
-
40
- + (ComponentDescriptorProvider)componentDescriptorProvider {
41
- return concreteComponentDescriptorProvider<
42
- LuggGoogleMapViewComponentDescriptor>();
43
- }
44
-
45
- - (instancetype)initWithFrame:(CGRect)frame {
46
- if (self = [super initWithFrame:frame]) {
47
- static const auto defaultProps =
48
- std::make_shared<const LuggGoogleMapViewProps>();
49
- _props = defaultProps;
50
-
51
- _isMapReady = NO;
52
- _mapId = kDemoMapId;
53
- _pendingMarkerViews = [NSMutableArray array];
54
- _pendingPolylineViews = [NSMutableArray array];
55
- _polylineAnimators = [NSMapTable weakToStrongObjectsMapTable];
56
- }
57
-
58
- return self;
59
- }
60
-
61
- #pragma mark - View Lifecycle
62
-
63
- - (void)mountChildComponentView:
64
- (UIView<RCTComponentViewProtocol> *)childComponentView
65
- index:(NSInteger)index {
66
- [super mountChildComponentView:childComponentView index:index];
67
-
68
- if ([childComponentView isKindOfClass:[LuggMapWrapperView class]]) {
69
- _mapWrapperView = (LuggMapWrapperView *)childComponentView;
70
- } else if ([childComponentView isKindOfClass:[LuggMarkerView class]]) {
71
- LuggMarkerView *markerView = (LuggMarkerView *)childComponentView;
72
- markerView.delegate = self;
73
- [self syncMarkerView:markerView caller:@"mountChildComponentView"];
74
- } else if ([childComponentView isKindOfClass:[LuggPolylineView class]]) {
75
- LuggPolylineView *polylineView = (LuggPolylineView *)childComponentView;
76
- polylineView.delegate = self;
77
- [self syncPolylineView:polylineView];
78
- }
79
- }
80
-
81
- - (void)unmountChildComponentView:
82
- (UIView<RCTComponentViewProtocol> *)childComponentView
83
- index:(NSInteger)index {
84
- if ([childComponentView isKindOfClass:[LuggMarkerView class]]) {
85
- LuggMarkerView *markerView = (LuggMarkerView *)childComponentView;
86
- GMSAdvancedMarker *marker = (GMSAdvancedMarker *)markerView.marker;
87
- if (marker) {
88
- marker.iconView = nil;
89
- marker.map = nil;
90
- markerView.marker = nil;
91
- }
92
- } else if ([childComponentView isKindOfClass:[LuggPolylineView class]]) {
93
- LuggPolylineView *polylineView = (LuggPolylineView *)childComponentView;
94
- [_polylineAnimators removeObjectForKey:polylineView];
95
- GMSPolyline *polyline = (GMSPolyline *)polylineView.polyline;
96
- if (polyline) {
97
- polyline.map = nil;
98
- polylineView.polyline = nil;
99
- }
100
- }
101
-
102
- [super unmountChildComponentView:childComponentView index:index];
103
- }
104
-
105
- - (void)didMoveToWindow {
106
- [super didMoveToWindow];
107
- if (self.window && !_mapView && _mapWrapperView) {
108
- [self initializeMap];
109
- }
110
- }
111
-
112
- - (void)prepareForRecycle {
113
- [super prepareForRecycle];
114
-
115
- [_pendingMarkerViews removeAllObjects];
116
- [_pendingPolylineViews removeAllObjects];
117
- [_polylineAnimators removeAllObjects];
118
- [_mapView clear];
119
- [_mapView removeFromSuperview];
120
- _mapView = nil;
121
- _mapWrapperView = nil;
122
- _isMapReady = NO;
123
- }
124
-
125
- #pragma mark - Map Initialization
126
-
127
- - (void)initializeMap {
128
- if (_mapView || !_mapWrapperView) {
129
- return;
130
- }
131
-
132
- const auto &viewProps =
133
- *std::static_pointer_cast<LuggGoogleMapViewProps const>(_props);
134
-
135
- GMSMapID *gmsMapId;
136
- if ([_mapId isEqualToString:kDemoMapId] || _mapId.length == 0) {
137
- gmsMapId = [GMSMapID demoMapID];
138
- } else {
139
- gmsMapId = [GMSMapID mapIDWithIdentifier:_mapId];
140
- }
141
-
142
- GMSCameraPosition *camera = [GMSCameraPosition
143
- cameraWithLatitude:viewProps.initialCoordinate.latitude
144
- longitude:viewProps.initialCoordinate.longitude
145
- zoom:viewProps.initialZoom];
146
-
147
- GMSMapViewOptions *options = [[GMSMapViewOptions alloc] init];
148
- options.frame = _mapWrapperView.bounds;
149
- options.camera = camera;
150
- options.mapID = gmsMapId;
151
-
152
- _mapView = [[GMSMapView alloc] initWithOptions:options];
153
- _mapView.autoresizingMask =
154
- UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
155
- _mapView.delegate = self;
156
- _mapView.paddingAdjustmentBehavior =
157
- kGMSMapViewPaddingAdjustmentBehaviorNever;
158
- _mapView.settings.zoomGestures = viewProps.zoomEnabled;
159
- _mapView.settings.scrollGestures = viewProps.scrollEnabled;
160
- _mapView.settings.rotateGestures = viewProps.rotateEnabled;
161
- _mapView.settings.tiltGestures = viewProps.pitchEnabled;
162
- _mapView.myLocationEnabled = viewProps.userLocationEnabled;
163
-
164
- if (viewProps.minZoom > 0) {
165
- [_mapView setMinZoom:(float)viewProps.minZoom maxZoom:_mapView.maxZoom];
166
- }
167
- if (viewProps.maxZoom > 0) {
168
- [_mapView setMinZoom:_mapView.minZoom maxZoom:(float)viewProps.maxZoom];
169
- }
170
-
171
- _mapView.padding =
172
- UIEdgeInsetsMake(viewProps.padding.top, viewProps.padding.left,
173
- viewProps.padding.bottom, viewProps.padding.right);
174
-
175
- [_mapWrapperView addSubview:_mapView];
176
-
177
- _isMapReady = YES;
178
- [self processPendingMarkers];
179
- [self processPendingPolylines];
180
-
181
- ReadyEvent::emit<LuggGoogleMapViewEventEmitter>(_eventEmitter);
182
- }
183
-
184
- - (GMSMapView *)mapView {
185
- return _mapView;
186
- }
187
-
188
- #pragma mark - GMSMapViewDelegate
189
-
190
- - (void)mapView:(GMSMapView *)mapView willMove:(BOOL)gesture {
191
- _isDragging = gesture;
192
- }
193
-
194
- - (void)mapView:(GMSMapView *)mapView
195
- didChangeCameraPosition:(GMSCameraPosition *)position {
196
- CameraMoveEvent{position.target.latitude, position.target.longitude,
197
- position.zoom, _isDragging}
198
- .emit<LuggGoogleMapViewEventEmitter>(_eventEmitter);
199
- }
200
-
201
- - (void)mapView:(GMSMapView *)mapView
202
- idleAtCameraPosition:(GMSCameraPosition *)position {
203
- BOOL wasDragging = _isDragging;
204
- _isDragging = NO;
205
- CameraIdleEvent{position.target.latitude, position.target.longitude,
206
- position.zoom, static_cast<bool>(wasDragging)}
207
- .emit<LuggGoogleMapViewEventEmitter>(_eventEmitter);
208
- }
209
-
210
- #pragma mark - PolylineViewDelegate
211
-
212
- - (void)polylineViewDidUpdate:(LuggPolylineView *)polylineView {
213
- [self syncPolylineView:polylineView];
214
- }
215
-
216
- #pragma mark - MarkerViewDelegate
217
-
218
- - (void)markerViewDidLayout:(LuggMarkerView *)markerView {
219
- [self syncMarkerView:markerView caller:@"markerViewDidLayout"];
220
- }
221
-
222
- - (void)markerViewDidUpdate:(LuggMarkerView *)markerView {
223
- [self syncMarkerView:markerView caller:@"markerViewDidUpdate"];
224
- }
225
-
226
- #pragma mark - Marker Management
227
-
228
- - (void)syncMarkerView:(LuggMarkerView *)markerView caller:(NSString *)caller {
229
- if (!_mapView) {
230
- if (![_pendingMarkerViews containsObject:markerView]) {
231
- [_pendingMarkerViews addObject:markerView];
232
- }
233
- return;
234
- }
235
-
236
- if (!markerView.marker) {
237
- [self addMarkerViewToMap:markerView];
238
- return;
239
- }
240
-
241
- GMSAdvancedMarker *marker = (GMSAdvancedMarker *)markerView.marker;
242
- marker.position = markerView.coordinate;
243
- marker.title = markerView.title;
244
- marker.snippet = markerView.markerDescription;
245
- marker.zIndex = (int)markerView.zIndex;
246
- if (markerView.hasCustomView) {
247
- UIView *iconView = markerView.iconView;
248
- [iconView removeFromSuperview];
249
- marker.iconView = iconView;
250
- marker.groundAnchor = markerView.anchor;
251
- } else {
252
- marker.iconView = nil;
253
- marker.groundAnchor = CGPointMake(0.5, 1);
254
- }
255
- }
256
-
257
- - (void)processPendingMarkers {
258
- if (!_mapView) {
259
- return;
260
- }
261
-
262
- for (LuggMarkerView *markerView in _pendingMarkerViews) {
263
- [self addMarkerViewToMap:markerView];
264
- }
265
- [_pendingMarkerViews removeAllObjects];
266
- }
267
-
268
- - (void)addMarkerViewToMap:(LuggMarkerView *)markerView {
269
- if (!_mapView) {
270
- RCTLogWarn(@"Lugg: addMarkerViewToMap called without a map");
271
- return;
272
- }
273
-
274
- UIView *iconView = markerView.iconView;
275
- [iconView removeFromSuperview];
276
-
277
- GMSAdvancedMarker *marker = [[GMSAdvancedMarker alloc] init];
278
- marker.position = markerView.coordinate;
279
- marker.title = markerView.title;
280
- marker.snippet = markerView.markerDescription;
281
-
282
- if (markerView.hasCustomView) {
283
- marker.iconView = iconView;
284
- marker.groundAnchor = markerView.anchor;
285
- }
286
-
287
- marker.zIndex = (int)markerView.zIndex;
288
- marker.map = _mapView;
289
-
290
- markerView.marker = marker;
291
- }
292
-
293
- #pragma mark - Polyline Management
294
-
295
- - (void)syncPolylineView:(LuggPolylineView *)polylineView {
296
- if (!_mapView) {
297
- if (![_pendingPolylineViews containsObject:polylineView]) {
298
- [_pendingPolylineViews addObject:polylineView];
299
- }
300
- return;
301
- }
302
-
303
- if (!polylineView.polyline) {
304
- [self addPolylineViewToMap:polylineView];
305
- return;
306
- }
307
-
308
- GMSPolyline *polyline = (GMSPolyline *)polylineView.polyline;
309
- polyline.strokeWidth = polylineView.strokeWidth;
310
-
311
- GMSPolylineAnimator *animator =
312
- [_polylineAnimators objectForKey:polylineView];
313
- if (animator) {
314
- animator.coordinates = polylineView.coordinates;
315
- animator.strokeColors = polylineView.strokeColors;
316
- animator.animated = polylineView.animated;
317
- [animator update];
318
- }
319
- }
320
-
321
- - (void)processPendingPolylines {
322
- if (!_mapView) {
323
- return;
324
- }
325
-
326
- for (LuggPolylineView *polylineView in _pendingPolylineViews) {
327
- [self addPolylineViewToMap:polylineView];
328
- }
329
- [_pendingPolylineViews removeAllObjects];
330
- }
331
-
332
- - (void)addPolylineViewToMap:(LuggPolylineView *)polylineView {
333
- if (!_mapView) {
334
- return;
335
- }
336
-
337
- GMSPolyline *polyline = [GMSPolyline polylineWithPath:[GMSMutablePath path]];
338
- polyline.strokeWidth = polylineView.strokeWidth;
339
- polyline.map = _mapView;
340
- polylineView.polyline = polyline;
341
-
342
- GMSPolylineAnimator *animator = [[GMSPolylineAnimator alloc] init];
343
- animator.polyline = polyline;
344
- animator.coordinates = polylineView.coordinates;
345
- animator.strokeColors = polylineView.strokeColors;
346
- animator.animated = polylineView.animated;
347
- [animator update];
348
-
349
- [_polylineAnimators setObject:animator forKey:polylineView];
350
- }
351
-
352
- #pragma mark - Property Setters
353
-
354
- - (void)updateProps:(Props::Shared const &)props
355
- oldProps:(Props::Shared const &)oldProps {
356
- const auto &newViewProps =
357
- *std::static_pointer_cast<LuggGoogleMapViewProps const>(props);
358
-
359
- if (_mapView == nil) {
360
- NSString *newMapId =
361
- [NSString stringWithUTF8String:newViewProps.mapId.c_str()];
362
- if (newMapId.length > 0) {
363
- _mapId = newMapId;
364
- }
365
- }
366
-
367
- if (_mapView) {
368
- _mapView.settings.zoomGestures = newViewProps.zoomEnabled;
369
- _mapView.settings.scrollGestures = newViewProps.scrollEnabled;
370
- _mapView.settings.rotateGestures = newViewProps.rotateEnabled;
371
- _mapView.settings.tiltGestures = newViewProps.pitchEnabled;
372
- _mapView.myLocationEnabled = newViewProps.userLocationEnabled;
373
- _mapView.padding = UIEdgeInsetsMake(
374
- newViewProps.padding.top, newViewProps.padding.left,
375
- newViewProps.padding.bottom, newViewProps.padding.right);
376
-
377
- float minZoom = newViewProps.minZoom > 0 ? (float)newViewProps.minZoom
378
- : _mapView.minZoom;
379
- float maxZoom = newViewProps.maxZoom > 0 ? (float)newViewProps.maxZoom
380
- : _mapView.maxZoom;
381
- [_mapView setMinZoom:minZoom maxZoom:maxZoom];
382
- }
383
-
384
- [super updateProps:props oldProps:oldProps];
385
- }
386
-
387
- #pragma mark - Commands
388
-
389
- - (void)moveCamera:(double)latitude
390
- longitude:(double)longitude
391
- zoom:(double)zoom
392
- duration:(double)duration {
393
- if (!_mapView) {
394
- return;
395
- }
396
-
397
- GMSCameraPosition *camera =
398
- [GMSCameraPosition cameraWithLatitude:latitude
399
- longitude:longitude
400
- zoom:(float)zoom];
401
- if (duration < 0) {
402
- [_mapView animateToCameraPosition:camera];
403
- } else if (duration > 0) {
404
- [CATransaction begin];
405
- [CATransaction setAnimationDuration:duration / 1000.0];
406
- [_mapView animateToCameraPosition:camera];
407
- [CATransaction commit];
408
- } else {
409
- [_mapView setCamera:camera];
410
- }
411
- }
412
-
413
- - (void)fitCoordinates:(NSArray *)coordinates
414
- paddingTop:(double)paddingTop
415
- paddingLeft:(double)paddingLeft
416
- paddingBottom:(double)paddingBottom
417
- paddingRight:(double)paddingRight
418
- duration:(double)duration {
419
- if (!_mapView || coordinates.count == 0) {
420
- return;
421
- }
422
-
423
- GMSCoordinateBounds *bounds = [[GMSCoordinateBounds alloc] init];
424
- for (NSDictionary *coord in coordinates) {
425
- double lat = [coord[@"latitude"] doubleValue];
426
- double lng = [coord[@"longitude"] doubleValue];
427
- bounds = [bounds includingCoordinate:CLLocationCoordinate2DMake(lat, lng)];
428
- }
429
-
430
- UIEdgeInsets edgePadding =
431
- UIEdgeInsetsMake(paddingTop, paddingLeft, paddingBottom, paddingRight);
432
- GMSCameraUpdate *cameraUpdate = [GMSCameraUpdate fitBounds:bounds
433
- withEdgeInsets:edgePadding];
434
-
435
- if (duration < 0) {
436
- [_mapView animateWithCameraUpdate:cameraUpdate];
437
- } else if (duration > 0) {
438
- [CATransaction begin];
439
- [CATransaction setAnimationDuration:duration / 1000.0];
440
- [_mapView animateWithCameraUpdate:cameraUpdate];
441
- [CATransaction commit];
442
- } else {
443
- [_mapView moveCamera:cameraUpdate];
444
- }
445
- }
446
-
447
- - (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args {
448
- RCTLuggGoogleMapViewHandleCommand(self, commandName, args);
449
- }
450
-
451
- Class<RCTComponentViewProtocol> LuggGoogleMapViewCls(void) {
452
- return LuggGoogleMapView.class;
453
- }
454
-
455
- @end
@@ -1,83 +0,0 @@
1
- import { codegenNativeComponent, codegenNativeCommands } from 'react-native';
2
- import type { ViewProps, HostComponent } from 'react-native';
3
- import type {
4
- Double,
5
- DirectEventHandler,
6
- } from 'react-native/Libraries/Types/CodegenTypes';
7
-
8
- export interface Coordinate {
9
- latitude: Double;
10
- longitude: Double;
11
- }
12
-
13
- export interface EdgeInsets {
14
- top: Double;
15
- left: Double;
16
- bottom: Double;
17
- right: Double;
18
- }
19
-
20
- export interface CameraMoveEvent {
21
- coordinate: {
22
- latitude: Double;
23
- longitude: Double;
24
- };
25
- zoom: Double;
26
- gesture: boolean;
27
- }
28
-
29
- export interface CameraIdleEvent {
30
- coordinate: {
31
- latitude: Double;
32
- longitude: Double;
33
- };
34
- zoom: Double;
35
- gesture: boolean;
36
- }
37
-
38
- export interface ReadyEvent {}
39
-
40
- export interface NativeProps extends ViewProps {
41
- initialCoordinate?: Coordinate;
42
- initialZoom?: Double;
43
- minZoom?: Double;
44
- maxZoom?: Double;
45
- zoomEnabled?: boolean;
46
- scrollEnabled?: boolean;
47
- rotateEnabled?: boolean;
48
- pitchEnabled?: boolean;
49
- padding?: EdgeInsets;
50
- userLocationEnabled?: boolean;
51
- onCameraMove?: DirectEventHandler<CameraMoveEvent>;
52
- onCameraIdle?: DirectEventHandler<CameraIdleEvent>;
53
- onReady?: DirectEventHandler<ReadyEvent>;
54
- }
55
-
56
- type ComponentType = HostComponent<NativeProps>;
57
-
58
- interface NativeCommands {
59
- moveCamera: (
60
- viewRef: React.ElementRef<ComponentType>,
61
- latitude: Double,
62
- longitude: Double,
63
- zoom: Double,
64
- duration: Double
65
- ) => void;
66
- fitCoordinates: (
67
- viewRef: React.ElementRef<ComponentType>,
68
- coordinates: Coordinate[],
69
- paddingTop: Double,
70
- paddingLeft: Double,
71
- paddingBottom: Double,
72
- paddingRight: Double,
73
- duration: Double
74
- ) => void;
75
- }
76
-
77
- export const Commands = codegenNativeCommands<NativeCommands>({
78
- supportedCommands: ['moveCamera', 'fitCoordinates'],
79
- });
80
-
81
- export default codegenNativeComponent<NativeProps>(
82
- 'LuggAppleMapView'
83
- ) as ComponentType;
@@ -1,54 +0,0 @@
1
- import type { ViewProps, HostComponent } from 'react-native';
2
- import type { Double, DirectEventHandler } from 'react-native/Libraries/Types/CodegenTypes';
3
- export interface Coordinate {
4
- latitude: Double;
5
- longitude: Double;
6
- }
7
- export interface EdgeInsets {
8
- top: Double;
9
- left: Double;
10
- bottom: Double;
11
- right: Double;
12
- }
13
- export interface CameraMoveEvent {
14
- coordinate: {
15
- latitude: Double;
16
- longitude: Double;
17
- };
18
- zoom: Double;
19
- gesture: boolean;
20
- }
21
- export interface CameraIdleEvent {
22
- coordinate: {
23
- latitude: Double;
24
- longitude: Double;
25
- };
26
- zoom: Double;
27
- gesture: boolean;
28
- }
29
- export interface ReadyEvent {
30
- }
31
- export interface NativeProps extends ViewProps {
32
- initialCoordinate?: Coordinate;
33
- initialZoom?: Double;
34
- minZoom?: Double;
35
- maxZoom?: Double;
36
- zoomEnabled?: boolean;
37
- scrollEnabled?: boolean;
38
- rotateEnabled?: boolean;
39
- pitchEnabled?: boolean;
40
- padding?: EdgeInsets;
41
- userLocationEnabled?: boolean;
42
- onCameraMove?: DirectEventHandler<CameraMoveEvent>;
43
- onCameraIdle?: DirectEventHandler<CameraIdleEvent>;
44
- onReady?: DirectEventHandler<ReadyEvent>;
45
- }
46
- type ComponentType = HostComponent<NativeProps>;
47
- interface NativeCommands {
48
- moveCamera: (viewRef: React.ElementRef<ComponentType>, latitude: Double, longitude: Double, zoom: Double, duration: Double) => void;
49
- fitCoordinates: (viewRef: React.ElementRef<ComponentType>, coordinates: Coordinate[], paddingTop: Double, paddingLeft: Double, paddingBottom: Double, paddingRight: Double, duration: Double) => void;
50
- }
51
- export declare const Commands: NativeCommands;
52
- declare const _default: ComponentType;
53
- export default _default;
54
- //# sourceMappingURL=LuggAppleMapViewNativeComponent.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LuggAppleMapViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../../src/fabric/LuggAppleMapViewNativeComponent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,KAAK,EACV,MAAM,EACN,kBAAkB,EACnB,MAAM,2CAA2C,CAAC;AAEnD,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAA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AAK,CAAC,UAAU,CAAC,aAAa,CAAC,EACxC,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,KACb,IAAI,CAAC;IACV,cAAc,EAAE,CACd,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,EACxC,WAAW,EAAE,UAAU,EAAE,EACzB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,KACb,IAAI,CAAC;CACX;AAED,eAAO,MAAM,QAAQ,gBAEnB,CAAC;wBAIE,aAAa;AAFlB,wBAEmB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"LuggGoogleMapViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../../src/fabric/LuggGoogleMapViewNativeComponent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,KAAK,EACV,MAAM,EACN,kBAAkB,EACnB,MAAM,2CAA2C,CAAC;AAEnD,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE;QACV,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE;QACV,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,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;CACX;AAED,eAAO,MAAM,QAAQ,gBAEnB,CAAC;wBAIE,aAAa;AAFlB,wBAEmB"}
@@ -1,83 +0,0 @@
1
- import { codegenNativeComponent, codegenNativeCommands } from 'react-native';
2
- import type { ViewProps, HostComponent } from 'react-native';
3
- import type {
4
- Double,
5
- DirectEventHandler,
6
- } from 'react-native/Libraries/Types/CodegenTypes';
7
-
8
- export interface Coordinate {
9
- latitude: Double;
10
- longitude: Double;
11
- }
12
-
13
- export interface EdgeInsets {
14
- top: Double;
15
- left: Double;
16
- bottom: Double;
17
- right: Double;
18
- }
19
-
20
- export interface CameraMoveEvent {
21
- coordinate: {
22
- latitude: Double;
23
- longitude: Double;
24
- };
25
- zoom: Double;
26
- gesture: boolean;
27
- }
28
-
29
- export interface CameraIdleEvent {
30
- coordinate: {
31
- latitude: Double;
32
- longitude: Double;
33
- };
34
- zoom: Double;
35
- gesture: boolean;
36
- }
37
-
38
- export interface ReadyEvent {}
39
-
40
- export interface NativeProps extends ViewProps {
41
- initialCoordinate?: Coordinate;
42
- initialZoom?: Double;
43
- minZoom?: Double;
44
- maxZoom?: Double;
45
- zoomEnabled?: boolean;
46
- scrollEnabled?: boolean;
47
- rotateEnabled?: boolean;
48
- pitchEnabled?: boolean;
49
- padding?: EdgeInsets;
50
- userLocationEnabled?: boolean;
51
- onCameraMove?: DirectEventHandler<CameraMoveEvent>;
52
- onCameraIdle?: DirectEventHandler<CameraIdleEvent>;
53
- onReady?: DirectEventHandler<ReadyEvent>;
54
- }
55
-
56
- type ComponentType = HostComponent<NativeProps>;
57
-
58
- interface NativeCommands {
59
- moveCamera: (
60
- viewRef: React.ElementRef<ComponentType>,
61
- latitude: Double,
62
- longitude: Double,
63
- zoom: Double,
64
- duration: Double
65
- ) => void;
66
- fitCoordinates: (
67
- viewRef: React.ElementRef<ComponentType>,
68
- coordinates: Coordinate[],
69
- paddingTop: Double,
70
- paddingLeft: Double,
71
- paddingBottom: Double,
72
- paddingRight: Double,
73
- duration: Double
74
- ) => void;
75
- }
76
-
77
- export const Commands = codegenNativeCommands<NativeCommands>({
78
- supportedCommands: ['moveCamera', 'fitCoordinates'],
79
- });
80
-
81
- export default codegenNativeComponent<NativeProps>(
82
- 'LuggAppleMapView'
83
- ) as ComponentType;