@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
@@ -1,454 +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.groundAnchor = markerView.anchor;
246
-
247
- if (markerView.hasCustomView) {
248
- UIView *iconView = markerView.iconView;
249
- [iconView removeFromSuperview];
250
- marker.iconView = iconView;
251
- } else {
252
- marker.iconView = nil;
253
- }
254
- }
255
-
256
- - (void)processPendingMarkers {
257
- if (!_mapView) {
258
- return;
259
- }
260
-
261
- for (LuggMarkerView *markerView in _pendingMarkerViews) {
262
- [self addMarkerViewToMap:markerView];
263
- }
264
- [_pendingMarkerViews removeAllObjects];
265
- }
266
-
267
- - (void)addMarkerViewToMap:(LuggMarkerView *)markerView {
268
- if (!_mapView) {
269
- RCTLogWarn(@"Lugg: addMarkerViewToMap called without a map");
270
- return;
271
- }
272
-
273
- UIView *iconView = markerView.iconView;
274
- [iconView removeFromSuperview];
275
-
276
- GMSAdvancedMarker *marker = [[GMSAdvancedMarker alloc] init];
277
- marker.position = markerView.coordinate;
278
- marker.title = markerView.title;
279
- marker.snippet = markerView.markerDescription;
280
- marker.collisionBehavior = GMSCollisionBehaviorRequired;
281
-
282
- if (markerView.hasCustomView) {
283
- marker.iconView = iconView;
284
- }
285
-
286
- marker.groundAnchor = markerView.anchor;
287
- marker.map = _mapView;
288
-
289
- markerView.marker = marker;
290
- }
291
-
292
- #pragma mark - Polyline Management
293
-
294
- - (void)syncPolylineView:(LuggPolylineView *)polylineView {
295
- if (!_mapView) {
296
- if (![_pendingPolylineViews containsObject:polylineView]) {
297
- [_pendingPolylineViews addObject:polylineView];
298
- }
299
- return;
300
- }
301
-
302
- if (!polylineView.polyline) {
303
- [self addPolylineViewToMap:polylineView];
304
- return;
305
- }
306
-
307
- GMSPolyline *polyline = (GMSPolyline *)polylineView.polyline;
308
- polyline.strokeWidth = polylineView.strokeWidth;
309
-
310
- GMSPolylineAnimator *animator =
311
- [_polylineAnimators objectForKey:polylineView];
312
- if (animator) {
313
- animator.coordinates = polylineView.coordinates;
314
- animator.strokeColors = polylineView.strokeColors;
315
- animator.animated = polylineView.animated;
316
- [animator update];
317
- }
318
- }
319
-
320
- - (void)processPendingPolylines {
321
- if (!_mapView) {
322
- return;
323
- }
324
-
325
- for (LuggPolylineView *polylineView in _pendingPolylineViews) {
326
- [self addPolylineViewToMap:polylineView];
327
- }
328
- [_pendingPolylineViews removeAllObjects];
329
- }
330
-
331
- - (void)addPolylineViewToMap:(LuggPolylineView *)polylineView {
332
- if (!_mapView) {
333
- return;
334
- }
335
-
336
- GMSPolyline *polyline = [GMSPolyline polylineWithPath:[GMSMutablePath path]];
337
- polyline.strokeWidth = polylineView.strokeWidth;
338
- polyline.map = _mapView;
339
- polylineView.polyline = polyline;
340
-
341
- GMSPolylineAnimator *animator = [[GMSPolylineAnimator alloc] init];
342
- animator.polyline = polyline;
343
- animator.coordinates = polylineView.coordinates;
344
- animator.strokeColors = polylineView.strokeColors;
345
- animator.animated = polylineView.animated;
346
- [animator update];
347
-
348
- [_polylineAnimators setObject:animator forKey:polylineView];
349
- }
350
-
351
- #pragma mark - Property Setters
352
-
353
- - (void)updateProps:(Props::Shared const &)props
354
- oldProps:(Props::Shared const &)oldProps {
355
- const auto &newViewProps =
356
- *std::static_pointer_cast<LuggGoogleMapViewProps const>(props);
357
-
358
- if (_mapView == nil) {
359
- NSString *newMapId =
360
- [NSString stringWithUTF8String:newViewProps.mapId.c_str()];
361
- if (newMapId.length > 0) {
362
- _mapId = newMapId;
363
- }
364
- }
365
-
366
- if (_mapView) {
367
- _mapView.settings.zoomGestures = newViewProps.zoomEnabled;
368
- _mapView.settings.scrollGestures = newViewProps.scrollEnabled;
369
- _mapView.settings.rotateGestures = newViewProps.rotateEnabled;
370
- _mapView.settings.tiltGestures = newViewProps.pitchEnabled;
371
- _mapView.myLocationEnabled = newViewProps.userLocationEnabled;
372
- _mapView.padding = UIEdgeInsetsMake(
373
- newViewProps.padding.top, newViewProps.padding.left,
374
- newViewProps.padding.bottom, newViewProps.padding.right);
375
-
376
- float minZoom = newViewProps.minZoom > 0 ? (float)newViewProps.minZoom
377
- : _mapView.minZoom;
378
- float maxZoom = newViewProps.maxZoom > 0 ? (float)newViewProps.maxZoom
379
- : _mapView.maxZoom;
380
- [_mapView setMinZoom:minZoom maxZoom:maxZoom];
381
- }
382
-
383
- [super updateProps:props oldProps:oldProps];
384
- }
385
-
386
- #pragma mark - Commands
387
-
388
- - (void)moveCamera:(double)latitude
389
- longitude:(double)longitude
390
- zoom:(double)zoom
391
- duration:(double)duration {
392
- if (!_mapView) {
393
- return;
394
- }
395
-
396
- GMSCameraPosition *camera =
397
- [GMSCameraPosition cameraWithLatitude:latitude
398
- longitude:longitude
399
- zoom:(float)zoom];
400
- if (duration < 0) {
401
- [_mapView animateToCameraPosition:camera];
402
- } else if (duration > 0) {
403
- [CATransaction begin];
404
- [CATransaction setAnimationDuration:duration / 1000.0];
405
- [_mapView animateToCameraPosition:camera];
406
- [CATransaction commit];
407
- } else {
408
- [_mapView setCamera:camera];
409
- }
410
- }
411
-
412
- - (void)fitCoordinates:(NSArray *)coordinates
413
- paddingTop:(double)paddingTop
414
- paddingLeft:(double)paddingLeft
415
- paddingBottom:(double)paddingBottom
416
- paddingRight:(double)paddingRight
417
- duration:(double)duration {
418
- if (!_mapView || coordinates.count == 0) {
419
- return;
420
- }
421
-
422
- GMSCoordinateBounds *bounds = [[GMSCoordinateBounds alloc] init];
423
- for (NSDictionary *coord in coordinates) {
424
- double lat = [coord[@"latitude"] doubleValue];
425
- double lng = [coord[@"longitude"] doubleValue];
426
- bounds = [bounds includingCoordinate:CLLocationCoordinate2DMake(lat, lng)];
427
- }
428
-
429
- UIEdgeInsets edgePadding =
430
- UIEdgeInsetsMake(paddingTop, paddingLeft, paddingBottom, paddingRight);
431
- GMSCameraUpdate *cameraUpdate = [GMSCameraUpdate fitBounds:bounds
432
- withEdgeInsets:edgePadding];
433
-
434
- if (duration < 0) {
435
- [_mapView animateWithCameraUpdate:cameraUpdate];
436
- } else if (duration > 0) {
437
- [CATransaction begin];
438
- [CATransaction setAnimationDuration:duration / 1000.0];
439
- [_mapView animateWithCameraUpdate:cameraUpdate];
440
- [CATransaction commit];
441
- } else {
442
- [_mapView moveCamera:cameraUpdate];
443
- }
444
- }
445
-
446
- - (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args {
447
- RCTLuggGoogleMapViewHandleCommand(self, commandName, args);
448
- }
449
-
450
- Class<RCTComponentViewProtocol> LuggGoogleMapViewCls(void) {
451
- return LuggGoogleMapView.class;
452
- }
453
-
454
- @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,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,MAAM,CAAC;KACnB,CAAC;IACF,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,UAAU;CAAG;AAE9B,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,iBAAiB,CAAC,EAAE,UAAU,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,UAAU,CAAC;IACrB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,YAAY,CAAC,EAAE,kBAAkB,CAAC,eAAe,CAAC,CAAC;IACnD,YAAY,CAAC,EAAE,kBAAkB,CAAC,eAAe,CAAC,CAAC;IACnD,OAAO,CAAC,EAAE,kBAAkB,CAAC,UAAU,CAAC,CAAC;CAC1C;AAED,KAAK,aAAa,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC;AAEhD,UAAU,cAAc;IACtB,UAAU,EAAE,CACV,OAAO,EAAE,KAAK,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,MAAM,CAAC;KACnB,CAAC;IACF,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,UAAU;CAAG;AAE9B,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iBAAiB,CAAC,EAAE,UAAU,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,UAAU,CAAC;IACrB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,YAAY,CAAC,EAAE,kBAAkB,CAAC,eAAe,CAAC,CAAC;IACnD,YAAY,CAAC,EAAE,kBAAkB,CAAC,eAAe,CAAC,CAAC;IACnD,OAAO,CAAC,EAAE,kBAAkB,CAAC,UAAU,CAAC,CAAC;CAC1C;AAED,KAAK,aAAa,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC;AAEhD,UAAU,cAAc;IACtB,UAAU,EAAE,CACV,OAAO,EAAE,KAAK,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,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;