@lugg/maps 0.2.0-alpha.22 → 0.2.0-alpha.24
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/README.md +5 -0
- package/android/src/main/java/com/luggmaps/LuggMapView.kt +241 -0
- package/android/src/main/java/com/luggmaps/{LuggGoogleMapViewManager.kt → LuggMapViewManager.kt} +36 -31
- package/android/src/main/java/com/luggmaps/LuggPackage.kt +1 -4
- package/android/src/main/java/com/luggmaps/{LuggGoogleMapView.kt → core/GoogleMapProvider.kt} +172 -212
- package/android/src/main/java/com/luggmaps/core/MapProviderDelegate.kt +53 -0
- package/android/src/main/java/com/luggmaps/core/PolylineAnimator.kt +32 -26
- package/ios/LuggMapView.h +9 -0
- package/ios/LuggMapView.mm +285 -0
- package/ios/core/AppleMapProvider.h +15 -0
- package/ios/{LuggAppleMapView.mm → core/AppleMapProvider.mm} +310 -421
- package/ios/core/GMSPolylineAnimator.m +16 -4
- package/ios/core/GoogleMapProvider.h +13 -0
- package/ios/{LuggGoogleMapView.mm → core/GoogleMapProvider.mm} +178 -238
- package/ios/core/MapProviderDelegate.h +68 -0
- package/lib/module/MapView.js +5 -11
- package/lib/module/MapView.js.map +1 -1
- package/lib/module/fabric/{LuggGoogleMapViewNativeComponent.ts → LuggMapViewNativeComponent.ts} +2 -1
- package/lib/typescript/src/MapView.d.ts +0 -1
- package/lib/typescript/src/MapView.d.ts.map +1 -1
- package/lib/typescript/src/fabric/{LuggGoogleMapViewNativeComponent.d.ts → LuggMapViewNativeComponent.d.ts} +2 -1
- package/lib/typescript/src/fabric/LuggMapViewNativeComponent.d.ts.map +1 -0
- package/package.json +3 -4
- package/src/MapView.tsx +8 -21
- package/src/fabric/{LuggGoogleMapViewNativeComponent.ts → LuggMapViewNativeComponent.ts} +2 -1
- package/ios/LuggAppleMapView.h +0 -16
- package/ios/LuggGoogleMapView.h +0 -13
- package/lib/module/fabric/LuggAppleMapViewNativeComponent.ts +0 -85
- package/lib/typescript/src/fabric/LuggAppleMapViewNativeComponent.d.ts +0 -55
- package/lib/typescript/src/fabric/LuggAppleMapViewNativeComponent.d.ts.map +0 -1
- package/lib/typescript/src/fabric/LuggGoogleMapViewNativeComponent.d.ts.map +0 -1
- package/src/fabric/LuggAppleMapViewNativeComponent.ts +0 -85
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
#import "GMSPolylineAnimator.h"
|
|
2
2
|
#import <QuartzCore/QuartzCore.h>
|
|
3
3
|
|
|
4
|
+
static const NSUInteger kMaxAnimationSpans = 16;
|
|
5
|
+
|
|
4
6
|
@interface GMSDisplayLinkProxy : NSObject
|
|
5
7
|
@property(nonatomic, weak) id target;
|
|
6
8
|
@property(nonatomic, assign) SEL selector;
|
|
@@ -245,12 +247,22 @@
|
|
|
245
247
|
}
|
|
246
248
|
|
|
247
249
|
NSUInteger pathCount = path.count;
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
250
|
+
NSUInteger segmentCount = pathCount - 1;
|
|
251
|
+
|
|
252
|
+
if (self.strokeColors.count <= 1) {
|
|
253
|
+
_polyline.path = path;
|
|
254
|
+
_polyline.strokeColor = self.strokeColors.firstObject ?: [UIColor blackColor];
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
NSUInteger spanCount = MIN(segmentCount, kMaxAnimationSpans);
|
|
259
|
+
double segmentsPerSpan = (double)segmentCount / spanCount;
|
|
260
|
+
|
|
261
|
+
for (NSUInteger i = 0; i < spanCount; i++) {
|
|
262
|
+
CGFloat gradientPos = ((CGFloat)i + 0.5) / spanCount;
|
|
251
263
|
UIColor *color = [self colorAtGradientPosition:gradientPos];
|
|
252
264
|
GMSStrokeStyle *style = [GMSStrokeStyle solidColor:color];
|
|
253
|
-
[spans addObject:[GMSStyleSpan spanWithStyle:style]];
|
|
265
|
+
[spans addObject:[GMSStyleSpan spanWithStyle:style segments:segmentsPerSpan]];
|
|
254
266
|
}
|
|
255
267
|
|
|
256
268
|
_polyline.path = path;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#import "MapProviderDelegate.h"
|
|
2
|
+
#import <GoogleMaps/GoogleMaps.h>
|
|
3
|
+
|
|
4
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
5
|
+
|
|
6
|
+
@interface GoogleMapProvider : NSObject <MapProvider, GMSMapViewDelegate>
|
|
7
|
+
|
|
8
|
+
@property(nonatomic, copy, nullable) NSString *mapId;
|
|
9
|
+
@property(nonatomic, readonly, nullable) GMSMapView *mapView;
|
|
10
|
+
|
|
11
|
+
@end
|
|
12
|
+
|
|
13
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -1,137 +1,53 @@
|
|
|
1
|
-
#import "
|
|
2
|
-
#import "LuggMarkerView.h"
|
|
3
|
-
#import "LuggPolylineView.h"
|
|
4
|
-
#import "
|
|
5
|
-
#import "
|
|
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"
|
|
1
|
+
#import "GoogleMapProvider.h"
|
|
2
|
+
#import "../LuggMarkerView.h"
|
|
3
|
+
#import "../LuggPolylineView.h"
|
|
4
|
+
#import "GMSPolylineAnimator.h"
|
|
5
|
+
#import "PolylineAnimatorBase.h"
|
|
21
6
|
|
|
22
7
|
static NSString *const kDemoMapId = @"DEMO_MAP_ID";
|
|
23
8
|
|
|
24
|
-
@interface
|
|
25
|
-
GMSMapViewDelegate, LuggMarkerViewDelegate,
|
|
9
|
+
@interface GoogleMapProvider () <LuggMarkerViewDelegate,
|
|
26
10
|
LuggPolylineViewDelegate>
|
|
27
11
|
@end
|
|
28
12
|
|
|
29
|
-
@implementation
|
|
13
|
+
@implementation GoogleMapProvider {
|
|
30
14
|
GMSMapView *_mapView;
|
|
31
|
-
LuggMapWrapperView *_mapWrapperView;
|
|
32
15
|
BOOL _isMapReady;
|
|
33
16
|
BOOL _isDragging;
|
|
34
|
-
NSString *
|
|
17
|
+
NSString *_theme;
|
|
35
18
|
NSMutableArray<LuggMarkerView *> *_pendingMarkerViews;
|
|
36
19
|
NSMutableArray<LuggPolylineView *> *_pendingPolylineViews;
|
|
37
20
|
NSMapTable<LuggPolylineView *, GMSPolylineAnimator *> *_polylineAnimators;
|
|
38
21
|
}
|
|
39
22
|
|
|
40
|
-
|
|
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;
|
|
23
|
+
@synthesize delegate = _delegate;
|
|
50
24
|
|
|
25
|
+
- (instancetype)init {
|
|
26
|
+
if (self = [super init]) {
|
|
51
27
|
_isMapReady = NO;
|
|
52
28
|
_mapId = kDemoMapId;
|
|
53
29
|
_pendingMarkerViews = [NSMutableArray array];
|
|
54
30
|
_pendingPolylineViews = [NSMutableArray array];
|
|
55
31
|
_polylineAnimators = [NSMapTable weakToStrongObjectsMapTable];
|
|
56
32
|
}
|
|
57
|
-
|
|
58
33
|
return self;
|
|
59
34
|
}
|
|
60
35
|
|
|
61
|
-
|
|
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
|
-
}
|
|
36
|
+
- (BOOL)isMapReady {
|
|
37
|
+
return _isMapReady;
|
|
79
38
|
}
|
|
80
39
|
|
|
81
|
-
- (
|
|
82
|
-
|
|
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
|
-
[markerView resetIconViewTransform];
|
|
93
|
-
} else if ([childComponentView isKindOfClass:[LuggPolylineView class]]) {
|
|
94
|
-
LuggPolylineView *polylineView = (LuggPolylineView *)childComponentView;
|
|
95
|
-
[_polylineAnimators removeObjectForKey:polylineView];
|
|
96
|
-
GMSPolyline *polyline = (GMSPolyline *)polylineView.polyline;
|
|
97
|
-
if (polyline) {
|
|
98
|
-
polyline.map = nil;
|
|
99
|
-
polylineView.polyline = nil;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
[super unmountChildComponentView:childComponentView index:index];
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
- (void)didMoveToWindow {
|
|
107
|
-
[super didMoveToWindow];
|
|
108
|
-
if (self.window && !_mapView && _mapWrapperView) {
|
|
109
|
-
[self initializeMap];
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
- (void)prepareForRecycle {
|
|
114
|
-
[super prepareForRecycle];
|
|
115
|
-
|
|
116
|
-
[_pendingMarkerViews removeAllObjects];
|
|
117
|
-
[_pendingPolylineViews removeAllObjects];
|
|
118
|
-
[_polylineAnimators removeAllObjects];
|
|
119
|
-
[_mapView clear];
|
|
120
|
-
[_mapView removeFromSuperview];
|
|
121
|
-
_mapView = nil;
|
|
122
|
-
_mapWrapperView = nil;
|
|
123
|
-
_isMapReady = NO;
|
|
40
|
+
- (GMSMapView *)mapView {
|
|
41
|
+
return _mapView;
|
|
124
42
|
}
|
|
125
43
|
|
|
126
|
-
#pragma mark -
|
|
44
|
+
#pragma mark - MapProvider
|
|
127
45
|
|
|
128
|
-
- (void)
|
|
129
|
-
|
|
46
|
+
- (void)initializeMapInView:(UIView *)wrapperView
|
|
47
|
+
initialCoordinate:(CLLocationCoordinate2D)coordinate
|
|
48
|
+
initialZoom:(double)zoom {
|
|
49
|
+
if (_mapView)
|
|
130
50
|
return;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
const auto &viewProps =
|
|
134
|
-
*std::static_pointer_cast<LuggGoogleMapViewProps const>(_props);
|
|
135
51
|
|
|
136
52
|
GMSMapID *gmsMapId;
|
|
137
53
|
if ([_mapId isEqualToString:kDemoMapId] || _mapId.length == 0) {
|
|
@@ -140,13 +56,13 @@ static NSString *const kDemoMapId = @"DEMO_MAP_ID";
|
|
|
140
56
|
gmsMapId = [GMSMapID mapIDWithIdentifier:_mapId];
|
|
141
57
|
}
|
|
142
58
|
|
|
143
|
-
GMSCameraPosition *camera =
|
|
144
|
-
cameraWithLatitude:
|
|
145
|
-
|
|
146
|
-
|
|
59
|
+
GMSCameraPosition *camera =
|
|
60
|
+
[GMSCameraPosition cameraWithLatitude:coordinate.latitude
|
|
61
|
+
longitude:coordinate.longitude
|
|
62
|
+
zoom:zoom];
|
|
147
63
|
|
|
148
64
|
GMSMapViewOptions *options = [[GMSMapViewOptions alloc] init];
|
|
149
|
-
options.frame =
|
|
65
|
+
options.frame = wrapperView.bounds;
|
|
150
66
|
options.camera = camera;
|
|
151
67
|
options.mapID = gmsMapId;
|
|
152
68
|
|
|
@@ -156,42 +72,84 @@ static NSString *const kDemoMapId = @"DEMO_MAP_ID";
|
|
|
156
72
|
_mapView.delegate = self;
|
|
157
73
|
_mapView.paddingAdjustmentBehavior =
|
|
158
74
|
kGMSMapViewPaddingAdjustmentBehaviorNever;
|
|
159
|
-
_mapView.settings.zoomGestures = viewProps.zoomEnabled;
|
|
160
|
-
_mapView.settings.scrollGestures = viewProps.scrollEnabled;
|
|
161
|
-
_mapView.settings.rotateGestures = viewProps.rotateEnabled;
|
|
162
|
-
_mapView.settings.tiltGestures = viewProps.pitchEnabled;
|
|
163
|
-
_mapView.myLocationEnabled = viewProps.userLocationEnabled;
|
|
164
75
|
|
|
165
|
-
|
|
76
|
+
[wrapperView addSubview:_mapView];
|
|
77
|
+
|
|
78
|
+
[self applyTheme];
|
|
79
|
+
|
|
80
|
+
_isMapReady = YES;
|
|
81
|
+
[self processPendingMarkers];
|
|
82
|
+
[self processPendingPolylines];
|
|
83
|
+
|
|
84
|
+
[_delegate mapProviderDidReady];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
- (void)destroy {
|
|
88
|
+
[_pendingMarkerViews removeAllObjects];
|
|
89
|
+
[_pendingPolylineViews removeAllObjects];
|
|
90
|
+
[_polylineAnimators removeAllObjects];
|
|
91
|
+
[_mapView clear];
|
|
92
|
+
[_mapView removeFromSuperview];
|
|
93
|
+
_mapView = nil;
|
|
94
|
+
_isMapReady = NO;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
#pragma mark - Props
|
|
98
|
+
|
|
99
|
+
- (void)setZoomEnabled:(BOOL)enabled {
|
|
100
|
+
_mapView.settings.zoomGestures = enabled;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
- (void)setScrollEnabled:(BOOL)enabled {
|
|
104
|
+
_mapView.settings.scrollGestures = enabled;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
- (void)setRotateEnabled:(BOOL)enabled {
|
|
108
|
+
_mapView.settings.rotateGestures = enabled;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
- (void)setPitchEnabled:(BOOL)enabled {
|
|
112
|
+
_mapView.settings.tiltGestures = enabled;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
- (void)setUserLocationEnabled:(BOOL)enabled {
|
|
116
|
+
_mapView.myLocationEnabled = enabled;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
- (void)setTheme:(NSString *)theme {
|
|
120
|
+
_theme = [theme copy];
|
|
121
|
+
[self applyTheme];
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
- (void)applyTheme {
|
|
125
|
+
if (!_mapView)
|
|
126
|
+
return;
|
|
127
|
+
|
|
128
|
+
if ([_theme isEqualToString:@"dark"]) {
|
|
166
129
|
_mapView.overrideUserInterfaceStyle = UIUserInterfaceStyleDark;
|
|
167
|
-
} else if (
|
|
130
|
+
} else if ([_theme isEqualToString:@"light"]) {
|
|
168
131
|
_mapView.overrideUserInterfaceStyle = UIUserInterfaceStyleLight;
|
|
169
132
|
} else {
|
|
170
133
|
_mapView.overrideUserInterfaceStyle = UIUserInterfaceStyleUnspecified;
|
|
171
134
|
}
|
|
135
|
+
}
|
|
172
136
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
_mapView.padding =
|
|
181
|
-
UIEdgeInsetsMake(viewProps.padding.top, viewProps.padding.left,
|
|
182
|
-
viewProps.padding.bottom, viewProps.padding.right);
|
|
183
|
-
|
|
184
|
-
[_mapWrapperView addSubview:_mapView];
|
|
185
|
-
|
|
186
|
-
_isMapReady = YES;
|
|
187
|
-
[self processPendingMarkers];
|
|
188
|
-
[self processPendingPolylines];
|
|
137
|
+
- (void)setMinZoom:(double)minZoom {
|
|
138
|
+
if (!_mapView)
|
|
139
|
+
return;
|
|
140
|
+
float min = minZoom > 0 ? (float)minZoom : _mapView.minZoom;
|
|
141
|
+
[_mapView setMinZoom:min maxZoom:_mapView.maxZoom];
|
|
142
|
+
}
|
|
189
143
|
|
|
190
|
-
|
|
144
|
+
- (void)setMaxZoom:(double)maxZoom {
|
|
145
|
+
if (!_mapView)
|
|
146
|
+
return;
|
|
147
|
+
float max = maxZoom > 0 ? (float)maxZoom : _mapView.maxZoom;
|
|
148
|
+
[_mapView setMinZoom:_mapView.minZoom maxZoom:max];
|
|
191
149
|
}
|
|
192
150
|
|
|
193
|
-
- (
|
|
194
|
-
|
|
151
|
+
- (void)setPadding:(UIEdgeInsets)padding oldPadding:(UIEdgeInsets)oldPadding {
|
|
152
|
+
_mapView.padding = padding;
|
|
195
153
|
}
|
|
196
154
|
|
|
197
155
|
#pragma mark - GMSMapViewDelegate
|
|
@@ -207,9 +165,10 @@ static NSString *const kDemoMapId = @"DEMO_MAP_ID";
|
|
|
207
165
|
|
|
208
166
|
- (void)mapView:(GMSMapView *)mapView
|
|
209
167
|
didChangeCameraPosition:(GMSCameraPosition *)position {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
168
|
+
[_delegate mapProviderDidMoveCamera:position.target.latitude
|
|
169
|
+
longitude:position.target.longitude
|
|
170
|
+
zoom:position.zoom
|
|
171
|
+
gesture:_isDragging];
|
|
213
172
|
}
|
|
214
173
|
|
|
215
174
|
- (void)mapView:(GMSMapView *)mapView
|
|
@@ -221,59 +180,46 @@ static NSString *const kDemoMapId = @"DEMO_MAP_ID";
|
|
|
221
180
|
[animator resume];
|
|
222
181
|
}
|
|
223
182
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
#pragma mark - PolylineViewDelegate
|
|
230
|
-
|
|
231
|
-
- (void)polylineViewDidUpdate:(LuggPolylineView *)polylineView {
|
|
232
|
-
[self syncPolylineView:polylineView];
|
|
183
|
+
[_delegate mapProviderDidIdleCamera:position.target.latitude
|
|
184
|
+
longitude:position.target.longitude
|
|
185
|
+
zoom:position.zoom
|
|
186
|
+
gesture:wasDragging];
|
|
233
187
|
}
|
|
234
188
|
|
|
235
189
|
#pragma mark - MarkerViewDelegate
|
|
236
190
|
|
|
237
191
|
- (void)markerViewDidLayout:(LuggMarkerView *)markerView {
|
|
238
|
-
[self syncMarkerView:markerView
|
|
192
|
+
[self syncMarkerView:markerView];
|
|
239
193
|
}
|
|
240
194
|
|
|
241
195
|
- (void)markerViewDidUpdate:(LuggMarkerView *)markerView {
|
|
242
|
-
[self syncMarkerView:markerView
|
|
196
|
+
[self syncMarkerView:markerView];
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
#pragma mark - PolylineViewDelegate
|
|
200
|
+
|
|
201
|
+
- (void)polylineViewDidUpdate:(LuggPolylineView *)polylineView {
|
|
202
|
+
[self syncPolylineView:polylineView];
|
|
243
203
|
}
|
|
244
204
|
|
|
245
205
|
#pragma mark - Marker Management
|
|
246
206
|
|
|
247
|
-
- (void)
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
UIView *iconView = markerView.iconView;
|
|
256
|
-
if (marker.iconView != iconView) {
|
|
257
|
-
[iconView removeFromSuperview];
|
|
258
|
-
marker.iconView = iconView;
|
|
259
|
-
}
|
|
260
|
-
CGFloat scale = markerView.scale;
|
|
261
|
-
CGFloat radians = markerView.rotate * M_PI / 180.0;
|
|
262
|
-
iconView.transform =
|
|
263
|
-
CGAffineTransformConcat(CGAffineTransformMakeScale(scale, scale),
|
|
264
|
-
CGAffineTransformMakeRotation(radians));
|
|
265
|
-
marker.rotation = 0;
|
|
266
|
-
}
|
|
267
|
-
marker.groundAnchor = markerView.anchor;
|
|
268
|
-
} else {
|
|
207
|
+
- (void)addMarkerView:(LuggMarkerView *)markerView {
|
|
208
|
+
markerView.delegate = self;
|
|
209
|
+
[self syncMarkerView:markerView];
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
- (void)removeMarkerView:(LuggMarkerView *)markerView {
|
|
213
|
+
GMSAdvancedMarker *marker = (GMSAdvancedMarker *)markerView.marker;
|
|
214
|
+
if (marker) {
|
|
269
215
|
marker.iconView = nil;
|
|
270
|
-
marker.
|
|
271
|
-
marker
|
|
272
|
-
marker.groundAnchor = CGPointMake(0.5, 1);
|
|
216
|
+
marker.map = nil;
|
|
217
|
+
markerView.marker = nil;
|
|
273
218
|
}
|
|
219
|
+
[markerView resetIconViewTransform];
|
|
274
220
|
}
|
|
275
221
|
|
|
276
|
-
- (void)syncMarkerView:(LuggMarkerView *)markerView
|
|
222
|
+
- (void)syncMarkerView:(LuggMarkerView *)markerView {
|
|
277
223
|
if (!_mapView) {
|
|
278
224
|
if (![_pendingMarkerViews containsObject:markerView]) {
|
|
279
225
|
[_pendingMarkerViews addObject:markerView];
|
|
@@ -295,9 +241,8 @@ static NSString *const kDemoMapId = @"DEMO_MAP_ID";
|
|
|
295
241
|
}
|
|
296
242
|
|
|
297
243
|
- (void)processPendingMarkers {
|
|
298
|
-
if (!_mapView)
|
|
244
|
+
if (!_mapView)
|
|
299
245
|
return;
|
|
300
|
-
}
|
|
301
246
|
|
|
302
247
|
for (LuggMarkerView *markerView in _pendingMarkerViews) {
|
|
303
248
|
[self addMarkerViewToMap:markerView];
|
|
@@ -306,10 +251,8 @@ static NSString *const kDemoMapId = @"DEMO_MAP_ID";
|
|
|
306
251
|
}
|
|
307
252
|
|
|
308
253
|
- (void)addMarkerViewToMap:(LuggMarkerView *)markerView {
|
|
309
|
-
if (!_mapView)
|
|
310
|
-
RCTLogWarn(@"Lugg: addMarkerViewToMap called without a map");
|
|
254
|
+
if (!_mapView)
|
|
311
255
|
return;
|
|
312
|
-
}
|
|
313
256
|
|
|
314
257
|
GMSAdvancedMarker *marker = [[GMSAdvancedMarker alloc] init];
|
|
315
258
|
marker.position = markerView.coordinate;
|
|
@@ -323,8 +266,51 @@ static NSString *const kDemoMapId = @"DEMO_MAP_ID";
|
|
|
323
266
|
markerView.marker = marker;
|
|
324
267
|
}
|
|
325
268
|
|
|
269
|
+
- (void)applyMarkerStyle:(LuggMarkerView *)markerView
|
|
270
|
+
marker:(GMSAdvancedMarker *)marker {
|
|
271
|
+
if (markerView.hasCustomView) {
|
|
272
|
+
if (markerView.rasterize) {
|
|
273
|
+
marker.iconView = nil;
|
|
274
|
+
marker.icon = [markerView createScaledIconImage];
|
|
275
|
+
marker.rotation = markerView.rotate;
|
|
276
|
+
} else {
|
|
277
|
+
UIView *iconView = markerView.iconView;
|
|
278
|
+
if (marker.iconView != iconView) {
|
|
279
|
+
[iconView removeFromSuperview];
|
|
280
|
+
marker.iconView = iconView;
|
|
281
|
+
}
|
|
282
|
+
CGFloat scale = markerView.scale;
|
|
283
|
+
CGFloat radians = markerView.rotate * M_PI / 180.0;
|
|
284
|
+
iconView.transform =
|
|
285
|
+
CGAffineTransformConcat(CGAffineTransformMakeScale(scale, scale),
|
|
286
|
+
CGAffineTransformMakeRotation(radians));
|
|
287
|
+
marker.rotation = 0;
|
|
288
|
+
}
|
|
289
|
+
marker.groundAnchor = markerView.anchor;
|
|
290
|
+
} else {
|
|
291
|
+
marker.iconView = nil;
|
|
292
|
+
marker.icon = nil;
|
|
293
|
+
marker.rotation = markerView.rotate;
|
|
294
|
+
marker.groundAnchor = CGPointMake(0.5, 1);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
326
298
|
#pragma mark - Polyline Management
|
|
327
299
|
|
|
300
|
+
- (void)addPolylineView:(LuggPolylineView *)polylineView {
|
|
301
|
+
polylineView.delegate = self;
|
|
302
|
+
[self syncPolylineView:polylineView];
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
- (void)removePolylineView:(LuggPolylineView *)polylineView {
|
|
306
|
+
[_polylineAnimators removeObjectForKey:polylineView];
|
|
307
|
+
GMSPolyline *polyline = (GMSPolyline *)polylineView.polyline;
|
|
308
|
+
if (polyline) {
|
|
309
|
+
polyline.map = nil;
|
|
310
|
+
polylineView.polyline = nil;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
328
314
|
- (void)syncPolylineView:(LuggPolylineView *)polylineView {
|
|
329
315
|
if (!_mapView) {
|
|
330
316
|
if (![_pendingPolylineViews containsObject:polylineView]) {
|
|
@@ -354,9 +340,8 @@ static NSString *const kDemoMapId = @"DEMO_MAP_ID";
|
|
|
354
340
|
}
|
|
355
341
|
|
|
356
342
|
- (void)processPendingPolylines {
|
|
357
|
-
if (!_mapView)
|
|
343
|
+
if (!_mapView)
|
|
358
344
|
return;
|
|
359
|
-
}
|
|
360
345
|
|
|
361
346
|
for (LuggPolylineView *polylineView in _pendingPolylineViews) {
|
|
362
347
|
[self addPolylineViewToMap:polylineView];
|
|
@@ -365,9 +350,8 @@ static NSString *const kDemoMapId = @"DEMO_MAP_ID";
|
|
|
365
350
|
}
|
|
366
351
|
|
|
367
352
|
- (void)addPolylineViewToMap:(LuggPolylineView *)polylineView {
|
|
368
|
-
if (!_mapView)
|
|
353
|
+
if (!_mapView)
|
|
369
354
|
return;
|
|
370
|
-
}
|
|
371
355
|
|
|
372
356
|
GMSPolyline *polyline = [GMSPolyline polylineWithPath:[GMSMutablePath path]];
|
|
373
357
|
polyline.strokeWidth = polylineView.strokeWidth;
|
|
@@ -386,52 +370,18 @@ static NSString *const kDemoMapId = @"DEMO_MAP_ID";
|
|
|
386
370
|
[_polylineAnimators setObject:animator forKey:polylineView];
|
|
387
371
|
}
|
|
388
372
|
|
|
389
|
-
#pragma mark -
|
|
390
|
-
|
|
391
|
-
- (void)updateProps:(Props::Shared const &)props
|
|
392
|
-
oldProps:(Props::Shared const &)oldProps {
|
|
393
|
-
const auto &oldViewProps =
|
|
394
|
-
*std::static_pointer_cast<LuggGoogleMapViewProps const>(oldProps);
|
|
395
|
-
const auto &newViewProps =
|
|
396
|
-
*std::static_pointer_cast<LuggGoogleMapViewProps const>(props);
|
|
373
|
+
#pragma mark - Lifecycle
|
|
397
374
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
if (newMapId.length > 0) {
|
|
402
|
-
_mapId = newMapId;
|
|
403
|
-
}
|
|
375
|
+
- (void)pauseAnimations {
|
|
376
|
+
for (GMSPolylineAnimator *animator in _polylineAnimators.objectEnumerator) {
|
|
377
|
+
[animator pause];
|
|
404
378
|
}
|
|
379
|
+
}
|
|
405
380
|
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
_mapView.settings.rotateGestures = newViewProps.rotateEnabled;
|
|
410
|
-
_mapView.settings.tiltGestures = newViewProps.pitchEnabled;
|
|
411
|
-
_mapView.myLocationEnabled = newViewProps.userLocationEnabled;
|
|
412
|
-
|
|
413
|
-
if (oldViewProps.theme != newViewProps.theme) {
|
|
414
|
-
if (newViewProps.theme == LuggGoogleMapViewTheme::Dark) {
|
|
415
|
-
_mapView.overrideUserInterfaceStyle = UIUserInterfaceStyleDark;
|
|
416
|
-
} else if (newViewProps.theme == LuggGoogleMapViewTheme::Light) {
|
|
417
|
-
_mapView.overrideUserInterfaceStyle = UIUserInterfaceStyleLight;
|
|
418
|
-
} else {
|
|
419
|
-
_mapView.overrideUserInterfaceStyle = UIUserInterfaceStyleUnspecified;
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
_mapView.padding = UIEdgeInsetsMake(
|
|
424
|
-
newViewProps.padding.top, newViewProps.padding.left,
|
|
425
|
-
newViewProps.padding.bottom, newViewProps.padding.right);
|
|
426
|
-
|
|
427
|
-
float minZoom = newViewProps.minZoom > 0 ? (float)newViewProps.minZoom
|
|
428
|
-
: _mapView.minZoom;
|
|
429
|
-
float maxZoom = newViewProps.maxZoom > 0 ? (float)newViewProps.maxZoom
|
|
430
|
-
: _mapView.maxZoom;
|
|
431
|
-
[_mapView setMinZoom:minZoom maxZoom:maxZoom];
|
|
381
|
+
- (void)resumeAnimations {
|
|
382
|
+
for (GMSPolylineAnimator *animator in _polylineAnimators.objectEnumerator) {
|
|
383
|
+
[animator resume];
|
|
432
384
|
}
|
|
433
|
-
|
|
434
|
-
[super updateProps:props oldProps:oldProps];
|
|
435
385
|
}
|
|
436
386
|
|
|
437
387
|
#pragma mark - Commands
|
|
@@ -440,9 +390,8 @@ static NSString *const kDemoMapId = @"DEMO_MAP_ID";
|
|
|
440
390
|
longitude:(double)longitude
|
|
441
391
|
zoom:(double)zoom
|
|
442
392
|
duration:(double)duration {
|
|
443
|
-
if (!_mapView)
|
|
393
|
+
if (!_mapView)
|
|
444
394
|
return;
|
|
445
|
-
}
|
|
446
395
|
|
|
447
396
|
float targetZoom = zoom > 0 ? (float)zoom : _mapView.camera.zoom;
|
|
448
397
|
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:latitude
|
|
@@ -466,9 +415,8 @@ static NSString *const kDemoMapId = @"DEMO_MAP_ID";
|
|
|
466
415
|
paddingBottom:(double)paddingBottom
|
|
467
416
|
paddingRight:(double)paddingRight
|
|
468
417
|
duration:(double)duration {
|
|
469
|
-
if (!_mapView || coordinates.count == 0)
|
|
418
|
+
if (!_mapView || coordinates.count == 0)
|
|
470
419
|
return;
|
|
471
|
-
}
|
|
472
420
|
|
|
473
421
|
GMSCoordinateBounds *bounds = [[GMSCoordinateBounds alloc] init];
|
|
474
422
|
for (NSDictionary *coord in coordinates) {
|
|
@@ -494,12 +442,4 @@ static NSString *const kDemoMapId = @"DEMO_MAP_ID";
|
|
|
494
442
|
}
|
|
495
443
|
}
|
|
496
444
|
|
|
497
|
-
- (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args {
|
|
498
|
-
RCTLuggGoogleMapViewHandleCommand(self, commandName, args);
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
Class<RCTComponentViewProtocol> LuggGoogleMapViewCls(void) {
|
|
502
|
-
return LuggGoogleMapView.class;
|
|
503
|
-
}
|
|
504
|
-
|
|
505
445
|
@end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#import <CoreLocation/CoreLocation.h>
|
|
2
|
+
#import <UIKit/UIKit.h>
|
|
3
|
+
|
|
4
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
5
|
+
|
|
6
|
+
@class LuggMarkerView;
|
|
7
|
+
@class LuggPolylineView;
|
|
8
|
+
|
|
9
|
+
@protocol MapProviderDelegate <NSObject>
|
|
10
|
+
- (void)mapProviderDidReady;
|
|
11
|
+
- (void)mapProviderDidMoveCamera:(double)latitude
|
|
12
|
+
longitude:(double)longitude
|
|
13
|
+
zoom:(double)zoom
|
|
14
|
+
gesture:(BOOL)gesture;
|
|
15
|
+
- (void)mapProviderDidIdleCamera:(double)latitude
|
|
16
|
+
longitude:(double)longitude
|
|
17
|
+
zoom:(double)zoom
|
|
18
|
+
gesture:(BOOL)gesture;
|
|
19
|
+
@end
|
|
20
|
+
|
|
21
|
+
@protocol MapProvider <NSObject>
|
|
22
|
+
|
|
23
|
+
@property(nonatomic, weak, nullable) id<MapProviderDelegate> delegate;
|
|
24
|
+
@property(nonatomic, readonly) BOOL isMapReady;
|
|
25
|
+
|
|
26
|
+
- (void)initializeMapInView:(UIView *)wrapperView
|
|
27
|
+
initialCoordinate:(CLLocationCoordinate2D)coordinate
|
|
28
|
+
initialZoom:(double)zoom;
|
|
29
|
+
- (void)destroy;
|
|
30
|
+
|
|
31
|
+
// Props
|
|
32
|
+
- (void)setZoomEnabled:(BOOL)enabled;
|
|
33
|
+
- (void)setScrollEnabled:(BOOL)enabled;
|
|
34
|
+
- (void)setRotateEnabled:(BOOL)enabled;
|
|
35
|
+
- (void)setPitchEnabled:(BOOL)enabled;
|
|
36
|
+
- (void)setUserLocationEnabled:(BOOL)enabled;
|
|
37
|
+
- (void)setTheme:(NSString *)theme;
|
|
38
|
+
- (void)setMinZoom:(double)minZoom;
|
|
39
|
+
- (void)setMaxZoom:(double)maxZoom;
|
|
40
|
+
- (void)setPadding:(UIEdgeInsets)padding oldPadding:(UIEdgeInsets)oldPadding;
|
|
41
|
+
|
|
42
|
+
// Children
|
|
43
|
+
- (void)addMarkerView:(LuggMarkerView *)markerView;
|
|
44
|
+
- (void)removeMarkerView:(LuggMarkerView *)markerView;
|
|
45
|
+
- (void)syncMarkerView:(LuggMarkerView *)markerView;
|
|
46
|
+
- (void)addPolylineView:(LuggPolylineView *)polylineView;
|
|
47
|
+
- (void)removePolylineView:(LuggPolylineView *)polylineView;
|
|
48
|
+
- (void)syncPolylineView:(LuggPolylineView *)polylineView;
|
|
49
|
+
|
|
50
|
+
// Lifecycle
|
|
51
|
+
- (void)pauseAnimations;
|
|
52
|
+
- (void)resumeAnimations;
|
|
53
|
+
|
|
54
|
+
// Commands
|
|
55
|
+
- (void)moveCamera:(double)latitude
|
|
56
|
+
longitude:(double)longitude
|
|
57
|
+
zoom:(double)zoom
|
|
58
|
+
duration:(double)duration;
|
|
59
|
+
- (void)fitCoordinates:(NSArray *)coordinates
|
|
60
|
+
paddingTop:(double)paddingTop
|
|
61
|
+
paddingLeft:(double)paddingLeft
|
|
62
|
+
paddingBottom:(double)paddingBottom
|
|
63
|
+
paddingRight:(double)paddingRight
|
|
64
|
+
duration:(double)duration;
|
|
65
|
+
|
|
66
|
+
@end
|
|
67
|
+
|
|
68
|
+
NS_ASSUME_NONNULL_END
|