@lugg/maps 0.2.0-alpha.0 → 0.2.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/java/com/luggmaps/{LuggMapsGoogleMapView.kt → LuggGoogleMapView.kt} +107 -30
- package/android/src/main/java/com/luggmaps/{LuggMapsGoogleMapViewManager.kt → LuggGoogleMapViewManager.kt} +66 -39
- package/android/src/main/java/com/luggmaps/{LuggMapsWrapperView.kt → LuggMapWrapperView.kt} +1 -1
- package/android/src/main/java/com/luggmaps/LuggMapWrapperViewManager.kt +25 -0
- package/android/src/main/java/com/luggmaps/{LuggMapsMarkerView.kt → LuggMarkerView.kt} +6 -6
- package/android/src/main/java/com/luggmaps/{LuggMapsMarkerViewManager.kt → LuggMarkerViewManager.kt} +17 -17
- package/android/src/main/java/com/luggmaps/{LuggMapsPackage.kt → LuggPackage.kt} +2 -2
- package/android/src/main/java/com/luggmaps/{LuggMapsPolylineView.kt → LuggPolylineView.kt} +4 -4
- package/android/src/main/java/com/luggmaps/{LuggMapsPolylineViewManager.kt → LuggPolylineViewManager.kt} +16 -16
- package/android/src/main/java/com/luggmaps/events/CameraIdleEvent.kt +10 -2
- package/android/src/main/java/com/luggmaps/events/CameraMoveEvent.kt +6 -5
- package/android/src/main/java/com/luggmaps/events/ReadyEvent.kt +12 -0
- package/android/src/main/java/com/luggmaps/extensions/ViewExtensions.kt +14 -0
- package/ios/{LuggMapsAppleMapView.h → LuggAppleMapView.h} +2 -2
- package/ios/{LuggMapsAppleMapView.mm → LuggAppleMapView.mm} +104 -68
- package/ios/{LuggMapsGoogleMapView.h → LuggGoogleMapView.h} +1 -1
- package/ios/{LuggMapsGoogleMapView.mm → LuggGoogleMapView.mm} +75 -60
- package/ios/{LuggMapsWrapperView.h → LuggMapWrapperView.h} +1 -1
- package/ios/{LuggMapsWrapperView.mm → LuggMapWrapperView.mm} +7 -7
- package/ios/{LuggMapsMarkerView.h → LuggMarkerView.h} +6 -6
- package/ios/{LuggMapsMarkerView.mm → LuggMarkerView.mm} +8 -8
- package/ios/{LuggMapsPolylineView.h → LuggPolylineView.h} +5 -5
- package/ios/{LuggMapsPolylineView.mm → LuggPolylineView.mm} +8 -8
- package/ios/events/CameraIdleEvent.h +6 -1
- package/ios/events/CameraMoveEvent.h +6 -3
- package/ios/events/ReadyEvent.h +20 -0
- package/lib/module/MapView.js +21 -7
- package/lib/module/MapView.js.map +1 -1
- package/lib/module/{Marker.js → components/Marker.js} +2 -2
- package/lib/module/components/Marker.js.map +1 -0
- package/lib/module/{Polyline.js → components/Polyline.js} +2 -2
- package/lib/module/components/Polyline.js.map +1 -0
- package/lib/module/components/index.js +5 -0
- package/lib/module/components/index.js.map +1 -0
- package/{src/fabric/LuggMapsAppleMapViewNativeComponent.ts → lib/module/fabric/LuggAppleMapViewNativeComponent.ts} +13 -3
- package/lib/module/fabric/{LuggMapsGoogleMapViewNativeComponent.ts → LuggGoogleMapViewNativeComponent.ts} +13 -3
- package/{src/fabric/LuggMapsWrapperViewNativeComponent.ts → lib/module/fabric/LuggMapWrapperViewNativeComponent.ts} +1 -1
- package/lib/module/fabric/{LuggMapsMarkerViewNativeComponent.ts → LuggMarkerViewNativeComponent.ts} +1 -1
- package/{src/fabric/LuggMapsPolylineViewNativeComponent.ts → lib/module/fabric/LuggPolylineViewNativeComponent.ts} +1 -1
- package/lib/module/index.js +1 -2
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/plugin/src/withLuggMapsAndroid.d.ts +6 -0
- package/lib/typescript/plugin/src/withLuggMapsAndroid.d.ts.map +1 -0
- package/lib/typescript/plugin/src/withLuggMapsIOS.d.ts +6 -0
- package/lib/typescript/plugin/src/withLuggMapsIOS.d.ts.map +1 -0
- package/lib/typescript/src/MapView.d.ts.map +1 -1
- package/lib/typescript/src/MapView.types.d.ts +24 -14
- package/lib/typescript/src/MapView.types.d.ts.map +1 -1
- package/lib/typescript/src/{Marker.types.d.ts → components/Marker.d.ts} +6 -5
- package/lib/typescript/src/components/Marker.d.ts.map +1 -0
- package/lib/typescript/src/{Polyline.types.d.ts → components/Polyline.d.ts} +6 -5
- package/lib/typescript/src/components/Polyline.d.ts.map +1 -0
- package/lib/typescript/src/components/index.d.ts +3 -0
- package/lib/typescript/src/components/index.d.ts.map +1 -0
- package/lib/typescript/src/fabric/{LuggMapsAppleMapViewNativeComponent.d.ts → LuggAppleMapViewNativeComponent.d.ts} +10 -3
- package/lib/typescript/src/fabric/LuggAppleMapViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/fabric/{LuggMapsGoogleMapViewNativeComponent.d.ts → LuggGoogleMapViewNativeComponent.d.ts} +10 -3
- package/lib/typescript/src/fabric/LuggGoogleMapViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/fabric/{LuggMapsWrapperViewNativeComponent.d.ts → LuggMapWrapperViewNativeComponent.d.ts} +1 -1
- package/lib/typescript/src/fabric/LuggMapWrapperViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/fabric/{LuggMapsMarkerViewNativeComponent.d.ts → LuggMarkerViewNativeComponent.d.ts} +1 -1
- package/lib/typescript/src/fabric/LuggMarkerViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/fabric/{LuggMapsPolylineViewNativeComponent.d.ts → LuggPolylineViewNativeComponent.d.ts} +1 -1
- package/lib/typescript/src/fabric/LuggPolylineViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +2 -5
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +6 -6
- package/plugin/build/index.js +4 -4
- package/{lib/typescript/plugin/src/withMapsAndroid.d.ts → plugin/build/withLuggMapsAndroid.d.ts} +0 -1
- package/plugin/build/withLuggMapsAndroid.js +15 -0
- package/{lib/typescript/plugin/src/withMapsIOS.d.ts → plugin/build/withLuggMapsIOS.d.ts} +0 -1
- package/plugin/build/withLuggMapsIOS.js +27 -0
- package/plugin/build/withMapsAndroid.d.ts +1 -1
- package/plugin/build/withMapsIOS.d.ts +1 -1
- package/src/MapView.tsx +27 -10
- package/src/MapView.types.ts +24 -15
- package/src/components/Marker.tsx +59 -0
- package/src/{Polyline.tsx → components/Polyline.tsx} +23 -3
- package/src/components/index.ts +2 -0
- package/{lib/module/fabric/LuggMapsAppleMapViewNativeComponent.ts → src/fabric/LuggAppleMapViewNativeComponent.ts} +13 -3
- package/src/fabric/{LuggMapsGoogleMapViewNativeComponent.ts → LuggGoogleMapViewNativeComponent.ts} +13 -3
- package/{lib/module/fabric/LuggMapsWrapperViewNativeComponent.ts → src/fabric/LuggMapWrapperViewNativeComponent.ts} +1 -1
- package/src/fabric/{LuggMapsMarkerViewNativeComponent.ts → LuggMarkerViewNativeComponent.ts} +1 -1
- package/{lib/module/fabric/LuggMapsPolylineViewNativeComponent.ts → src/fabric/LuggPolylineViewNativeComponent.ts} +1 -1
- package/src/index.ts +3 -6
- package/android/src/main/java/com/luggmaps/LuggMapsWrapperViewManager.kt +0 -25
- package/lib/module/Marker.js.map +0 -1
- package/lib/module/Marker.types.js +0 -4
- package/lib/module/Marker.types.js.map +0 -1
- package/lib/module/Polyline.js.map +0 -1
- package/lib/module/Polyline.types.js +0 -4
- package/lib/module/Polyline.types.js.map +0 -1
- package/lib/typescript/plugin/src/withMapsAndroid.d.ts.map +0 -1
- package/lib/typescript/plugin/src/withMapsIOS.d.ts.map +0 -1
- package/lib/typescript/src/Marker.d.ts +0 -6
- package/lib/typescript/src/Marker.d.ts.map +0 -1
- package/lib/typescript/src/Marker.types.d.ts.map +0 -1
- package/lib/typescript/src/Polyline.d.ts +0 -6
- package/lib/typescript/src/Polyline.d.ts.map +0 -1
- package/lib/typescript/src/Polyline.types.d.ts.map +0 -1
- package/lib/typescript/src/fabric/LuggMapsAppleMapViewNativeComponent.d.ts.map +0 -1
- package/lib/typescript/src/fabric/LuggMapsGoogleMapViewNativeComponent.d.ts.map +0 -1
- package/lib/typescript/src/fabric/LuggMapsMarkerViewNativeComponent.d.ts.map +0 -1
- package/lib/typescript/src/fabric/LuggMapsPolylineViewNativeComponent.d.ts.map +0 -1
- package/lib/typescript/src/fabric/LuggMapsWrapperViewNativeComponent.d.ts.map +0 -1
- package/src/Marker.tsx +0 -31
- package/src/Marker.types.ts +0 -32
- package/src/Polyline.types.ts +0 -24
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
#import "
|
|
2
|
-
#import "
|
|
3
|
-
#import "
|
|
1
|
+
#import "LuggGoogleMapView.h"
|
|
2
|
+
#import "LuggMarkerView.h"
|
|
3
|
+
#import "LuggPolylineView.h"
|
|
4
4
|
#import "core/GMSPolylineAnimator.h"
|
|
5
5
|
#import "core/PolylineAnimatorBase.h"
|
|
6
6
|
#import "events/CameraIdleEvent.h"
|
|
7
7
|
#import "events/CameraMoveEvent.h"
|
|
8
|
+
#import "events/ReadyEvent.h"
|
|
8
9
|
|
|
9
10
|
#import <react/renderer/components/RNMapsSpec/ComponentDescriptors.h>
|
|
10
11
|
#import <react/renderer/components/RNMapsSpec/EventEmitters.h>
|
|
@@ -16,35 +17,35 @@
|
|
|
16
17
|
using namespace facebook::react;
|
|
17
18
|
using namespace luggmaps::events;
|
|
18
19
|
|
|
19
|
-
#import "
|
|
20
|
+
#import "LuggMapWrapperView.h"
|
|
20
21
|
|
|
21
22
|
static NSString *const kDemoMapId = @"DEMO_MAP_ID";
|
|
22
23
|
|
|
23
|
-
@interface
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
@interface LuggGoogleMapView () <RCTLuggGoogleMapViewViewProtocol,
|
|
25
|
+
GMSMapViewDelegate, LuggMarkerViewDelegate,
|
|
26
|
+
LuggPolylineViewDelegate>
|
|
26
27
|
@end
|
|
27
28
|
|
|
28
|
-
@implementation
|
|
29
|
+
@implementation LuggGoogleMapView {
|
|
29
30
|
GMSMapView *_mapView;
|
|
30
|
-
|
|
31
|
+
LuggMapWrapperView *_mapWrapperView;
|
|
31
32
|
BOOL _isMapReady;
|
|
32
33
|
BOOL _isDragging;
|
|
33
34
|
NSString *_mapId;
|
|
34
|
-
NSMutableArray<
|
|
35
|
-
NSMutableArray<
|
|
36
|
-
NSMapTable<
|
|
35
|
+
NSMutableArray<LuggMarkerView *> *_pendingMarkerViews;
|
|
36
|
+
NSMutableArray<LuggPolylineView *> *_pendingPolylineViews;
|
|
37
|
+
NSMapTable<LuggPolylineView *, GMSPolylineAnimator *> *_polylineAnimators;
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
+ (ComponentDescriptorProvider)componentDescriptorProvider {
|
|
40
41
|
return concreteComponentDescriptorProvider<
|
|
41
|
-
|
|
42
|
+
LuggGoogleMapViewComponentDescriptor>();
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
- (instancetype)initWithFrame:(CGRect)frame {
|
|
45
46
|
if (self = [super initWithFrame:frame]) {
|
|
46
47
|
static const auto defaultProps =
|
|
47
|
-
std::make_shared<const
|
|
48
|
+
std::make_shared<const LuggGoogleMapViewProps>();
|
|
48
49
|
_props = defaultProps;
|
|
49
50
|
|
|
50
51
|
_isMapReady = NO;
|
|
@@ -64,15 +65,14 @@ static NSString *const kDemoMapId = @"DEMO_MAP_ID";
|
|
|
64
65
|
index:(NSInteger)index {
|
|
65
66
|
[super mountChildComponentView:childComponentView index:index];
|
|
66
67
|
|
|
67
|
-
if ([childComponentView isKindOfClass:[
|
|
68
|
-
_mapWrapperView = (
|
|
69
|
-
} else if ([childComponentView isKindOfClass:[
|
|
70
|
-
|
|
68
|
+
if ([childComponentView isKindOfClass:[LuggMapWrapperView class]]) {
|
|
69
|
+
_mapWrapperView = (LuggMapWrapperView *)childComponentView;
|
|
70
|
+
} else if ([childComponentView isKindOfClass:[LuggMarkerView class]]) {
|
|
71
|
+
LuggMarkerView *markerView = (LuggMarkerView *)childComponentView;
|
|
71
72
|
markerView.delegate = self;
|
|
72
73
|
[self syncMarkerView:markerView caller:@"mountChildComponentView"];
|
|
73
|
-
} else if ([childComponentView isKindOfClass:[
|
|
74
|
-
|
|
75
|
-
(LuggMapsPolylineView *)childComponentView;
|
|
74
|
+
} else if ([childComponentView isKindOfClass:[LuggPolylineView class]]) {
|
|
75
|
+
LuggPolylineView *polylineView = (LuggPolylineView *)childComponentView;
|
|
76
76
|
polylineView.delegate = self;
|
|
77
77
|
[self syncPolylineView:polylineView];
|
|
78
78
|
}
|
|
@@ -81,17 +81,16 @@ static NSString *const kDemoMapId = @"DEMO_MAP_ID";
|
|
|
81
81
|
- (void)unmountChildComponentView:
|
|
82
82
|
(UIView<RCTComponentViewProtocol> *)childComponentView
|
|
83
83
|
index:(NSInteger)index {
|
|
84
|
-
if ([childComponentView isKindOfClass:[
|
|
85
|
-
|
|
84
|
+
if ([childComponentView isKindOfClass:[LuggMarkerView class]]) {
|
|
85
|
+
LuggMarkerView *markerView = (LuggMarkerView *)childComponentView;
|
|
86
86
|
GMSAdvancedMarker *marker = (GMSAdvancedMarker *)markerView.marker;
|
|
87
87
|
if (marker) {
|
|
88
88
|
marker.iconView = nil;
|
|
89
89
|
marker.map = nil;
|
|
90
90
|
markerView.marker = nil;
|
|
91
91
|
}
|
|
92
|
-
} else if ([childComponentView isKindOfClass:[
|
|
93
|
-
|
|
94
|
-
(LuggMapsPolylineView *)childComponentView;
|
|
92
|
+
} else if ([childComponentView isKindOfClass:[LuggPolylineView class]]) {
|
|
93
|
+
LuggPolylineView *polylineView = (LuggPolylineView *)childComponentView;
|
|
95
94
|
[_polylineAnimators removeObjectForKey:polylineView];
|
|
96
95
|
GMSPolyline *polyline = (GMSPolyline *)polylineView.polyline;
|
|
97
96
|
if (polyline) {
|
|
@@ -131,7 +130,7 @@ static NSString *const kDemoMapId = @"DEMO_MAP_ID";
|
|
|
131
130
|
}
|
|
132
131
|
|
|
133
132
|
const auto &viewProps =
|
|
134
|
-
*std::static_pointer_cast<
|
|
133
|
+
*std::static_pointer_cast<LuggGoogleMapViewProps const>(_props);
|
|
135
134
|
|
|
136
135
|
GMSMapID *gmsMapId;
|
|
137
136
|
if ([_mapId isEqualToString:kDemoMapId] || _mapId.length == 0) {
|
|
@@ -160,12 +159,26 @@ static NSString *const kDemoMapId = @"DEMO_MAP_ID";
|
|
|
160
159
|
_mapView.settings.scrollGestures = viewProps.scrollEnabled;
|
|
161
160
|
_mapView.settings.rotateGestures = viewProps.rotateEnabled;
|
|
162
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);
|
|
163
174
|
|
|
164
175
|
[_mapWrapperView addSubview:_mapView];
|
|
165
176
|
|
|
166
177
|
_isMapReady = YES;
|
|
167
178
|
[self processPendingMarkers];
|
|
168
179
|
[self processPendingPolylines];
|
|
180
|
+
|
|
181
|
+
ReadyEvent::emit<LuggGoogleMapViewEventEmitter>(_eventEmitter);
|
|
169
182
|
}
|
|
170
183
|
|
|
171
184
|
- (GMSMapView *)mapView {
|
|
@@ -180,49 +193,39 @@ static NSString *const kDemoMapId = @"DEMO_MAP_ID";
|
|
|
180
193
|
|
|
181
194
|
- (void)mapView:(GMSMapView *)mapView
|
|
182
195
|
didChangeCameraPosition:(GMSCameraPosition *)position {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
_eventEmitter);
|
|
187
|
-
CameraMoveEvent{position.target.latitude, position.target.longitude,
|
|
188
|
-
position.zoom, _isDragging}
|
|
189
|
-
.emit(emitter);
|
|
190
|
-
}
|
|
196
|
+
CameraMoveEvent{position.target.latitude, position.target.longitude,
|
|
197
|
+
position.zoom, _isDragging}
|
|
198
|
+
.emit<LuggGoogleMapViewEventEmitter>(_eventEmitter);
|
|
191
199
|
}
|
|
192
200
|
|
|
193
201
|
- (void)mapView:(GMSMapView *)mapView
|
|
194
202
|
idleAtCameraPosition:(GMSCameraPosition *)position {
|
|
203
|
+
BOOL wasDragging = _isDragging;
|
|
195
204
|
_isDragging = NO;
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
_eventEmitter);
|
|
200
|
-
CameraIdleEvent{position.target.latitude, position.target.longitude,
|
|
201
|
-
position.zoom}
|
|
202
|
-
.emit(emitter);
|
|
203
|
-
}
|
|
205
|
+
CameraIdleEvent{position.target.latitude, position.target.longitude,
|
|
206
|
+
position.zoom, static_cast<bool>(wasDragging)}
|
|
207
|
+
.emit<LuggGoogleMapViewEventEmitter>(_eventEmitter);
|
|
204
208
|
}
|
|
205
209
|
|
|
206
210
|
#pragma mark - PolylineViewDelegate
|
|
207
211
|
|
|
208
|
-
- (void)polylineViewDidUpdate:(
|
|
212
|
+
- (void)polylineViewDidUpdate:(LuggPolylineView *)polylineView {
|
|
209
213
|
[self syncPolylineView:polylineView];
|
|
210
214
|
}
|
|
211
215
|
|
|
212
216
|
#pragma mark - MarkerViewDelegate
|
|
213
217
|
|
|
214
|
-
- (void)markerViewDidLayout:(
|
|
218
|
+
- (void)markerViewDidLayout:(LuggMarkerView *)markerView {
|
|
215
219
|
[self syncMarkerView:markerView caller:@"markerViewDidLayout"];
|
|
216
220
|
}
|
|
217
221
|
|
|
218
|
-
- (void)markerViewDidUpdate:(
|
|
222
|
+
- (void)markerViewDidUpdate:(LuggMarkerView *)markerView {
|
|
219
223
|
[self syncMarkerView:markerView caller:@"markerViewDidUpdate"];
|
|
220
224
|
}
|
|
221
225
|
|
|
222
226
|
#pragma mark - Marker Management
|
|
223
227
|
|
|
224
|
-
- (void)syncMarkerView:(
|
|
225
|
-
caller:(NSString *)caller {
|
|
228
|
+
- (void)syncMarkerView:(LuggMarkerView *)markerView caller:(NSString *)caller {
|
|
226
229
|
if (!_mapView) {
|
|
227
230
|
if (![_pendingMarkerViews containsObject:markerView]) {
|
|
228
231
|
[_pendingMarkerViews addObject:markerView];
|
|
@@ -255,15 +258,15 @@ static NSString *const kDemoMapId = @"DEMO_MAP_ID";
|
|
|
255
258
|
return;
|
|
256
259
|
}
|
|
257
260
|
|
|
258
|
-
for (
|
|
261
|
+
for (LuggMarkerView *markerView in _pendingMarkerViews) {
|
|
259
262
|
[self addMarkerViewToMap:markerView];
|
|
260
263
|
}
|
|
261
264
|
[_pendingMarkerViews removeAllObjects];
|
|
262
265
|
}
|
|
263
266
|
|
|
264
|
-
- (void)addMarkerViewToMap:(
|
|
267
|
+
- (void)addMarkerViewToMap:(LuggMarkerView *)markerView {
|
|
265
268
|
if (!_mapView) {
|
|
266
|
-
RCTLogWarn(@"
|
|
269
|
+
RCTLogWarn(@"Lugg: addMarkerViewToMap called without a map");
|
|
267
270
|
return;
|
|
268
271
|
}
|
|
269
272
|
|
|
@@ -288,7 +291,7 @@ static NSString *const kDemoMapId = @"DEMO_MAP_ID";
|
|
|
288
291
|
|
|
289
292
|
#pragma mark - Polyline Management
|
|
290
293
|
|
|
291
|
-
- (void)syncPolylineView:(
|
|
294
|
+
- (void)syncPolylineView:(LuggPolylineView *)polylineView {
|
|
292
295
|
if (!_mapView) {
|
|
293
296
|
if (![_pendingPolylineViews containsObject:polylineView]) {
|
|
294
297
|
[_pendingPolylineViews addObject:polylineView];
|
|
@@ -319,13 +322,13 @@ static NSString *const kDemoMapId = @"DEMO_MAP_ID";
|
|
|
319
322
|
return;
|
|
320
323
|
}
|
|
321
324
|
|
|
322
|
-
for (
|
|
325
|
+
for (LuggPolylineView *polylineView in _pendingPolylineViews) {
|
|
323
326
|
[self addPolylineViewToMap:polylineView];
|
|
324
327
|
}
|
|
325
328
|
[_pendingPolylineViews removeAllObjects];
|
|
326
329
|
}
|
|
327
330
|
|
|
328
|
-
- (void)addPolylineViewToMap:(
|
|
331
|
+
- (void)addPolylineViewToMap:(LuggPolylineView *)polylineView {
|
|
329
332
|
if (!_mapView) {
|
|
330
333
|
return;
|
|
331
334
|
}
|
|
@@ -350,7 +353,7 @@ static NSString *const kDemoMapId = @"DEMO_MAP_ID";
|
|
|
350
353
|
- (void)updateProps:(Props::Shared const &)props
|
|
351
354
|
oldProps:(Props::Shared const &)oldProps {
|
|
352
355
|
const auto &newViewProps =
|
|
353
|
-
*std::static_pointer_cast<
|
|
356
|
+
*std::static_pointer_cast<LuggGoogleMapViewProps const>(props);
|
|
354
357
|
|
|
355
358
|
if (_mapView == nil) {
|
|
356
359
|
NSString *newMapId =
|
|
@@ -365,9 +368,16 @@ static NSString *const kDemoMapId = @"DEMO_MAP_ID";
|
|
|
365
368
|
_mapView.settings.scrollGestures = newViewProps.scrollEnabled;
|
|
366
369
|
_mapView.settings.rotateGestures = newViewProps.rotateEnabled;
|
|
367
370
|
_mapView.settings.tiltGestures = newViewProps.pitchEnabled;
|
|
371
|
+
_mapView.myLocationEnabled = newViewProps.userLocationEnabled;
|
|
368
372
|
_mapView.padding = UIEdgeInsetsMake(
|
|
369
373
|
newViewProps.padding.top, newViewProps.padding.left,
|
|
370
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];
|
|
371
381
|
}
|
|
372
382
|
|
|
373
383
|
[super updateProps:props oldProps:oldProps];
|
|
@@ -400,7 +410,10 @@ static NSString *const kDemoMapId = @"DEMO_MAP_ID";
|
|
|
400
410
|
}
|
|
401
411
|
|
|
402
412
|
- (void)fitCoordinates:(NSArray *)coordinates
|
|
403
|
-
|
|
413
|
+
paddingTop:(double)paddingTop
|
|
414
|
+
paddingLeft:(double)paddingLeft
|
|
415
|
+
paddingBottom:(double)paddingBottom
|
|
416
|
+
paddingRight:(double)paddingRight
|
|
404
417
|
duration:(double)duration {
|
|
405
418
|
if (!_mapView || coordinates.count == 0) {
|
|
406
419
|
return;
|
|
@@ -413,8 +426,10 @@ static NSString *const kDemoMapId = @"DEMO_MAP_ID";
|
|
|
413
426
|
bounds = [bounds includingCoordinate:CLLocationCoordinate2DMake(lat, lng)];
|
|
414
427
|
}
|
|
415
428
|
|
|
429
|
+
UIEdgeInsets edgePadding =
|
|
430
|
+
UIEdgeInsetsMake(paddingTop, paddingLeft, paddingBottom, paddingRight);
|
|
416
431
|
GMSCameraUpdate *cameraUpdate = [GMSCameraUpdate fitBounds:bounds
|
|
417
|
-
|
|
432
|
+
withEdgeInsets:edgePadding];
|
|
418
433
|
|
|
419
434
|
if (duration < 0) {
|
|
420
435
|
[_mapView animateWithCameraUpdate:cameraUpdate];
|
|
@@ -429,11 +444,11 @@ static NSString *const kDemoMapId = @"DEMO_MAP_ID";
|
|
|
429
444
|
}
|
|
430
445
|
|
|
431
446
|
- (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args {
|
|
432
|
-
|
|
447
|
+
RCTLuggGoogleMapViewHandleCommand(self, commandName, args);
|
|
433
448
|
}
|
|
434
449
|
|
|
435
|
-
Class<RCTComponentViewProtocol>
|
|
436
|
-
return
|
|
450
|
+
Class<RCTComponentViewProtocol> LuggGoogleMapViewCls(void) {
|
|
451
|
+
return LuggGoogleMapView.class;
|
|
437
452
|
}
|
|
438
453
|
|
|
439
454
|
@end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#import "
|
|
1
|
+
#import "LuggMapWrapperView.h"
|
|
2
2
|
|
|
3
3
|
#import <react/renderer/components/RNMapsSpec/ComponentDescriptors.h>
|
|
4
4
|
#import <react/renderer/components/RNMapsSpec/EventEmitters.h>
|
|
@@ -9,28 +9,28 @@
|
|
|
9
9
|
|
|
10
10
|
using namespace facebook::react;
|
|
11
11
|
|
|
12
|
-
@interface
|
|
12
|
+
@interface LuggMapWrapperView () <RCTLuggMapWrapperViewViewProtocol>
|
|
13
13
|
@end
|
|
14
14
|
|
|
15
|
-
@implementation
|
|
15
|
+
@implementation LuggMapWrapperView
|
|
16
16
|
|
|
17
17
|
+ (ComponentDescriptorProvider)componentDescriptorProvider {
|
|
18
18
|
return concreteComponentDescriptorProvider<
|
|
19
|
-
|
|
19
|
+
LuggMapWrapperViewComponentDescriptor>();
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
- (instancetype)initWithFrame:(CGRect)frame {
|
|
23
23
|
if (self = [super initWithFrame:frame]) {
|
|
24
24
|
static const auto defaultProps =
|
|
25
|
-
std::make_shared<const
|
|
25
|
+
std::make_shared<const LuggMapWrapperViewProps>();
|
|
26
26
|
_props = defaultProps;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
return self;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
Class<RCTComponentViewProtocol>
|
|
33
|
-
return
|
|
32
|
+
Class<RCTComponentViewProtocol> LuggMapWrapperViewCls(void) {
|
|
33
|
+
return LuggMapWrapperView.class;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
@end
|
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
NS_ASSUME_NONNULL_BEGIN
|
|
6
6
|
|
|
7
|
-
@class
|
|
7
|
+
@class LuggMarkerView;
|
|
8
8
|
|
|
9
|
-
@protocol
|
|
9
|
+
@protocol LuggMarkerViewDelegate <NSObject>
|
|
10
10
|
@optional
|
|
11
|
-
- (void)markerViewDidLayout:(
|
|
12
|
-
- (void)markerViewDidUpdate:(
|
|
11
|
+
- (void)markerViewDidLayout:(LuggMarkerView *)markerView;
|
|
12
|
+
- (void)markerViewDidUpdate:(LuggMarkerView *)markerView;
|
|
13
13
|
@end
|
|
14
14
|
|
|
15
|
-
@interface
|
|
15
|
+
@interface LuggMarkerView : RCTViewComponentView
|
|
16
16
|
|
|
17
17
|
@property(nonatomic, readonly) CLLocationCoordinate2D coordinate;
|
|
18
18
|
@property(nonatomic, readonly, nullable) NSString *title;
|
|
@@ -21,7 +21,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
21
21
|
@property(nonatomic, readonly) BOOL hasCustomView;
|
|
22
22
|
@property(nonatomic, readonly) BOOL didLayout;
|
|
23
23
|
@property(nonatomic, readonly) UIView *iconView;
|
|
24
|
-
@property(nonatomic, weak, nullable) id<
|
|
24
|
+
@property(nonatomic, weak, nullable) id<LuggMarkerViewDelegate> delegate;
|
|
25
25
|
@property(nonatomic, strong, nullable) NSObject *marker;
|
|
26
26
|
|
|
27
27
|
@end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#import "
|
|
1
|
+
#import "LuggMarkerView.h"
|
|
2
2
|
|
|
3
3
|
#import <react/renderer/components/RNMapsSpec/ComponentDescriptors.h>
|
|
4
4
|
#import <react/renderer/components/RNMapsSpec/EventEmitters.h>
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
|
|
10
10
|
using namespace facebook::react;
|
|
11
11
|
|
|
12
|
-
@interface
|
|
12
|
+
@interface LuggMarkerView () <RCTLuggMarkerViewViewProtocol>
|
|
13
13
|
@end
|
|
14
14
|
|
|
15
|
-
@implementation
|
|
15
|
+
@implementation LuggMarkerView {
|
|
16
16
|
CLLocationCoordinate2D _coordinate;
|
|
17
17
|
NSString *_title;
|
|
18
18
|
NSString *_markerDescription;
|
|
@@ -23,13 +23,13 @@ using namespace facebook::react;
|
|
|
23
23
|
|
|
24
24
|
+ (ComponentDescriptorProvider)componentDescriptorProvider {
|
|
25
25
|
return concreteComponentDescriptorProvider<
|
|
26
|
-
|
|
26
|
+
LuggMarkerViewComponentDescriptor>();
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
- (instancetype)initWithFrame:(CGRect)frame {
|
|
30
30
|
if (self = [super initWithFrame:frame]) {
|
|
31
31
|
static const auto defaultProps =
|
|
32
|
-
std::make_shared<const
|
|
32
|
+
std::make_shared<const LuggMarkerViewProps>();
|
|
33
33
|
_props = defaultProps;
|
|
34
34
|
|
|
35
35
|
_coordinate = CLLocationCoordinate2DMake(0, 0);
|
|
@@ -50,7 +50,7 @@ using namespace facebook::react;
|
|
|
50
50
|
oldProps:(Props::Shared const &)oldProps {
|
|
51
51
|
[super updateProps:props oldProps:oldProps];
|
|
52
52
|
const auto &newViewProps =
|
|
53
|
-
*std::static_pointer_cast<
|
|
53
|
+
*std::static_pointer_cast<LuggMarkerViewProps const>(props);
|
|
54
54
|
|
|
55
55
|
_coordinate = CLLocationCoordinate2DMake(newViewProps.coordinate.latitude,
|
|
56
56
|
newViewProps.coordinate.longitude);
|
|
@@ -147,8 +147,8 @@ using namespace facebook::react;
|
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
Class<RCTComponentViewProtocol>
|
|
151
|
-
return
|
|
150
|
+
Class<RCTComponentViewProtocol> LuggMarkerViewCls(void) {
|
|
151
|
+
return LuggMarkerView.class;
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
@end
|
|
@@ -4,20 +4,20 @@
|
|
|
4
4
|
|
|
5
5
|
NS_ASSUME_NONNULL_BEGIN
|
|
6
6
|
|
|
7
|
-
@class
|
|
7
|
+
@class LuggPolylineView;
|
|
8
8
|
|
|
9
|
-
@protocol
|
|
9
|
+
@protocol LuggPolylineViewDelegate <NSObject>
|
|
10
10
|
@optional
|
|
11
|
-
- (void)polylineViewDidUpdate:(
|
|
11
|
+
- (void)polylineViewDidUpdate:(LuggPolylineView *)polylineView;
|
|
12
12
|
@end
|
|
13
13
|
|
|
14
|
-
@interface
|
|
14
|
+
@interface LuggPolylineView : RCTViewComponentView
|
|
15
15
|
|
|
16
16
|
@property(nonatomic, readonly) NSArray<CLLocation *> *coordinates;
|
|
17
17
|
@property(nonatomic, readonly) NSArray<UIColor *> *strokeColors;
|
|
18
18
|
@property(nonatomic, readonly) BOOL animated;
|
|
19
19
|
@property(nonatomic, readonly) CGFloat strokeWidth;
|
|
20
|
-
@property(nonatomic, weak, nullable) id<
|
|
20
|
+
@property(nonatomic, weak, nullable) id<LuggPolylineViewDelegate> delegate;
|
|
21
21
|
@property(nonatomic, strong, nullable) NSObject *polyline;
|
|
22
22
|
@property(nonatomic, weak, nullable) NSObject *renderer;
|
|
23
23
|
@property(nonatomic, strong, nullable) NSArray *cachedSpans;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#import "
|
|
1
|
+
#import "LuggPolylineView.h"
|
|
2
2
|
|
|
3
3
|
#import <react/renderer/components/RNMapsSpec/ComponentDescriptors.h>
|
|
4
4
|
#import <react/renderer/components/RNMapsSpec/EventEmitters.h>
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
|
|
11
11
|
using namespace facebook::react;
|
|
12
12
|
|
|
13
|
-
@interface
|
|
13
|
+
@interface LuggPolylineView () <RCTLuggPolylineViewViewProtocol>
|
|
14
14
|
@end
|
|
15
15
|
|
|
16
|
-
@implementation
|
|
16
|
+
@implementation LuggPolylineView {
|
|
17
17
|
NSArray<CLLocation *> *_coordinates;
|
|
18
18
|
NSArray<UIColor *> *_strokeColors;
|
|
19
19
|
BOOL _animated;
|
|
@@ -22,13 +22,13 @@ using namespace facebook::react;
|
|
|
22
22
|
|
|
23
23
|
+ (ComponentDescriptorProvider)componentDescriptorProvider {
|
|
24
24
|
return concreteComponentDescriptorProvider<
|
|
25
|
-
|
|
25
|
+
LuggPolylineViewComponentDescriptor>();
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
- (instancetype)initWithFrame:(CGRect)frame {
|
|
29
29
|
if (self = [super initWithFrame:frame]) {
|
|
30
30
|
static const auto defaultProps =
|
|
31
|
-
std::make_shared<const
|
|
31
|
+
std::make_shared<const LuggPolylineViewProps>();
|
|
32
32
|
_props = defaultProps;
|
|
33
33
|
|
|
34
34
|
_coordinates = @[];
|
|
@@ -45,7 +45,7 @@ using namespace facebook::react;
|
|
|
45
45
|
oldProps:(Props::Shared const &)oldProps {
|
|
46
46
|
[super updateProps:props oldProps:oldProps];
|
|
47
47
|
const auto &newViewProps =
|
|
48
|
-
*std::static_pointer_cast<
|
|
48
|
+
*std::static_pointer_cast<LuggPolylineViewProps const>(props);
|
|
49
49
|
|
|
50
50
|
NSMutableArray<CLLocation *> *coords = [NSMutableArray array];
|
|
51
51
|
for (const auto &coord : newViewProps.coordinates) {
|
|
@@ -109,8 +109,8 @@ using namespace facebook::react;
|
|
|
109
109
|
self.delegate = nil;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
Class<RCTComponentViewProtocol>
|
|
113
|
-
return
|
|
112
|
+
Class<RCTComponentViewProtocol> LuggPolylineViewCls(void) {
|
|
113
|
+
return LuggPolylineView.class;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
@end
|
|
@@ -9,13 +9,18 @@ struct CameraIdleEvent {
|
|
|
9
9
|
double latitude;
|
|
10
10
|
double longitude;
|
|
11
11
|
double zoom;
|
|
12
|
+
bool gesture;
|
|
12
13
|
|
|
13
14
|
template <typename Emitter>
|
|
14
|
-
void emit(
|
|
15
|
+
void emit(const facebook::react::SharedEventEmitter &eventEmitter) const {
|
|
16
|
+
if (!eventEmitter)
|
|
17
|
+
return;
|
|
18
|
+
auto emitter = std::static_pointer_cast<Emitter const>(eventEmitter);
|
|
15
19
|
typename Emitter::OnCameraIdle event;
|
|
16
20
|
event.coordinate.latitude = latitude;
|
|
17
21
|
event.coordinate.longitude = longitude;
|
|
18
22
|
event.zoom = zoom;
|
|
23
|
+
event.gesture = gesture;
|
|
19
24
|
emitter->onCameraIdle(event);
|
|
20
25
|
}
|
|
21
26
|
};
|
|
@@ -9,15 +9,18 @@ struct CameraMoveEvent {
|
|
|
9
9
|
double latitude;
|
|
10
10
|
double longitude;
|
|
11
11
|
double zoom;
|
|
12
|
-
bool
|
|
12
|
+
bool gesture;
|
|
13
13
|
|
|
14
14
|
template <typename Emitter>
|
|
15
|
-
void emit(
|
|
15
|
+
void emit(const facebook::react::SharedEventEmitter &eventEmitter) const {
|
|
16
|
+
if (!eventEmitter)
|
|
17
|
+
return;
|
|
18
|
+
auto emitter = std::static_pointer_cast<Emitter const>(eventEmitter);
|
|
16
19
|
typename Emitter::OnCameraMove event;
|
|
17
20
|
event.coordinate.latitude = latitude;
|
|
18
21
|
event.coordinate.longitude = longitude;
|
|
19
22
|
event.zoom = zoom;
|
|
20
|
-
event.
|
|
23
|
+
event.gesture = gesture;
|
|
21
24
|
emitter->onCameraMove(event);
|
|
22
25
|
}
|
|
23
26
|
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#import <react/renderer/components/RNMapsSpec/EventEmitters.h>
|
|
4
|
+
|
|
5
|
+
namespace luggmaps {
|
|
6
|
+
namespace events {
|
|
7
|
+
|
|
8
|
+
struct ReadyEvent {
|
|
9
|
+
template <typename Emitter>
|
|
10
|
+
static void emit(const facebook::react::SharedEventEmitter &eventEmitter) {
|
|
11
|
+
if (!eventEmitter)
|
|
12
|
+
return;
|
|
13
|
+
auto emitter = std::static_pointer_cast<Emitter const>(eventEmitter);
|
|
14
|
+
typename Emitter::OnReady event;
|
|
15
|
+
emitter->onReady(event);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
} // namespace events
|
|
20
|
+
} // namespace luggmaps
|
package/lib/module/MapView.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { Platform, StyleSheet } from 'react-native';
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
5
|
+
import LuggGoogleMapViewNativeComponent, { Commands as GoogleMapCommands } from './fabric/LuggGoogleMapViewNativeComponent';
|
|
6
|
+
import LuggAppleMapViewNativeComponent, { Commands as AppleMapCommands } from './fabric/LuggAppleMapViewNativeComponent';
|
|
7
|
+
import LuggMapWrapperViewNativeComponent from './fabric/LuggMapWrapperViewNativeComponent';
|
|
8
8
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
9
|
export class MapView extends React.Component {
|
|
10
10
|
static defaultProps = {
|
|
@@ -35,9 +35,15 @@ export class MapView extends React.Component {
|
|
|
35
35
|
const first = coordinates[0];
|
|
36
36
|
if (!ref || !first) return;
|
|
37
37
|
const {
|
|
38
|
-
padding
|
|
38
|
+
padding,
|
|
39
39
|
duration = -1
|
|
40
40
|
} = options ?? {};
|
|
41
|
+
const {
|
|
42
|
+
top = 0,
|
|
43
|
+
left = 0,
|
|
44
|
+
bottom = 0,
|
|
45
|
+
right = 0
|
|
46
|
+
} = padding ?? {};
|
|
41
47
|
if (coordinates.length === 1) {
|
|
42
48
|
const zoom = this.props.initialZoom ?? 10;
|
|
43
49
|
this.moveCamera(first, {
|
|
@@ -46,7 +52,7 @@ export class MapView extends React.Component {
|
|
|
46
52
|
});
|
|
47
53
|
return;
|
|
48
54
|
}
|
|
49
|
-
this.nativeCommands.fitCoordinates(ref, coordinates,
|
|
55
|
+
this.nativeCommands.fitCoordinates(ref, coordinates, top, left, bottom, right, duration);
|
|
50
56
|
}
|
|
51
57
|
render() {
|
|
52
58
|
const {
|
|
@@ -54,31 +60,39 @@ export class MapView extends React.Component {
|
|
|
54
60
|
mapId,
|
|
55
61
|
initialCoordinate,
|
|
56
62
|
initialZoom,
|
|
63
|
+
minZoom,
|
|
64
|
+
maxZoom,
|
|
57
65
|
zoomEnabled,
|
|
58
66
|
scrollEnabled,
|
|
59
67
|
rotateEnabled,
|
|
60
68
|
pitchEnabled,
|
|
61
69
|
padding,
|
|
70
|
+
userLocationEnabled,
|
|
62
71
|
onCameraMove,
|
|
63
72
|
onCameraIdle,
|
|
73
|
+
onReady,
|
|
64
74
|
children,
|
|
65
75
|
...rest
|
|
66
76
|
} = this.props;
|
|
67
|
-
const NativeMapView = Platform.OS === 'ios' && provider === 'apple' ?
|
|
77
|
+
const NativeMapView = Platform.OS === 'ios' && provider === 'apple' ? LuggAppleMapViewNativeComponent : LuggGoogleMapViewNativeComponent;
|
|
68
78
|
return /*#__PURE__*/_jsxs(NativeMapView, {
|
|
69
79
|
ref: this.nativeRef,
|
|
70
80
|
...rest,
|
|
71
81
|
mapId: mapId,
|
|
72
82
|
initialCoordinate: initialCoordinate,
|
|
73
83
|
initialZoom: initialZoom,
|
|
84
|
+
minZoom: minZoom,
|
|
85
|
+
maxZoom: maxZoom,
|
|
74
86
|
zoomEnabled: zoomEnabled,
|
|
75
87
|
scrollEnabled: scrollEnabled,
|
|
76
88
|
rotateEnabled: rotateEnabled,
|
|
77
89
|
pitchEnabled: pitchEnabled,
|
|
78
90
|
padding: padding,
|
|
91
|
+
userLocationEnabled: userLocationEnabled,
|
|
79
92
|
onCameraMove: onCameraMove,
|
|
80
93
|
onCameraIdle: onCameraIdle,
|
|
81
|
-
|
|
94
|
+
onReady: onReady,
|
|
95
|
+
children: [/*#__PURE__*/_jsx(LuggMapWrapperViewNativeComponent, {
|
|
82
96
|
style: StyleSheet.absoluteFill
|
|
83
97
|
}), children]
|
|
84
98
|
});
|