@lugg/maps 0.2.0-alpha.0 → 0.2.0-alpha.10
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 +17 -4
- package/android/src/main/java/com/luggmaps/{LuggMapsGoogleMapView.kt → LuggGoogleMapView.kt} +111 -36
- 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} +13 -7
- package/android/src/main/java/com/luggmaps/{LuggMapsMarkerViewManager.kt → LuggMarkerViewManager.kt} +23 -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} +11 -4
- package/android/src/main/java/com/luggmaps/{LuggMapsPolylineViewManager.kt → LuggPolylineViewManager.kt} +22 -16
- package/android/src/main/java/com/luggmaps/core/PolylineAnimator.kt +89 -43
- 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} +140 -71
- package/ios/{LuggMapsGoogleMapView.h → LuggGoogleMapView.h} +1 -1
- package/ios/{LuggMapsGoogleMapView.mm → LuggGoogleMapView.mm} +82 -64
- package/ios/{LuggMapsWrapperView.h → LuggMapWrapperView.h} +1 -1
- package/ios/{LuggMapsWrapperView.mm → LuggMapWrapperView.mm} +7 -7
- package/ios/{LuggMapsMarkerView.h → LuggMarkerView.h} +8 -6
- package/ios/{LuggMapsMarkerView.mm → LuggMarkerView.mm} +21 -8
- package/ios/{LuggMapsPolylineView.h → LuggPolylineView.h} +6 -5
- package/ios/{LuggMapsPolylineView.mm → LuggPolylineView.mm} +14 -9
- package/ios/core/GMSPolylineAnimator.m +85 -36
- package/ios/core/MKPolylineAnimator.m +63 -32
- package/ios/events/CameraIdleEvent.h +6 -1
- package/ios/events/CameraMoveEvent.h +6 -3
- package/ios/events/ReadyEvent.h +20 -0
- package/lib/module/MapProvider.js +13 -0
- package/lib/module/MapProvider.js.map +1 -0
- package/lib/module/MapProvider.types.js +4 -0
- package/lib/module/MapProvider.types.js.map +1 -0
- package/lib/module/MapProvider.web.js +14 -0
- package/lib/module/MapProvider.web.js.map +1 -0
- package/lib/module/MapView.js +21 -7
- package/lib/module/MapView.js.map +1 -1
- package/lib/module/MapView.web.js +266 -0
- package/lib/module/MapView.web.js.map +1 -0
- package/lib/module/{Marker.js → components/Marker.js} +6 -3
- package/lib/module/components/Marker.js.map +1 -0
- package/lib/module/components/Marker.web.js +34 -0
- package/lib/module/components/Marker.web.js.map +1 -0
- package/lib/module/{Polyline.js → components/Polyline.js} +7 -4
- package/lib/module/components/Polyline.js.map +1 -0
- package/lib/module/components/Polyline.web.js +177 -0
- package/lib/module/components/Polyline.web.js.map +1 -0
- package/lib/module/components/index.js +5 -0
- package/lib/module/components/index.js.map +1 -0
- package/lib/module/components/index.web.js +5 -0
- package/lib/module/components/index.web.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 +3 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js +6 -0
- package/lib/module/index.web.js.map +1 -0
- 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/MapProvider.d.ts +8 -0
- package/lib/typescript/src/MapProvider.d.ts.map +1 -0
- package/lib/typescript/src/MapProvider.types.d.ts +16 -0
- package/lib/typescript/src/MapProvider.types.d.ts.map +1 -0
- package/lib/typescript/src/MapProvider.web.d.ts +3 -0
- package/lib/typescript/src/MapProvider.web.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/MapView.web.d.ts +12 -0
- package/lib/typescript/src/MapView.web.d.ts.map +1 -0
- package/lib/typescript/src/{Marker.types.d.ts → components/Marker.d.ts} +10 -5
- package/lib/typescript/src/components/Marker.d.ts.map +1 -0
- package/lib/typescript/src/{Marker.d.ts → components/Marker.web.d.ts} +2 -2
- package/lib/typescript/src/components/Marker.web.d.ts.map +1 -0
- package/lib/typescript/src/{Polyline.types.d.ts → components/Polyline.d.ts} +10 -5
- package/lib/typescript/src/components/Polyline.d.ts.map +1 -0
- package/lib/typescript/src/components/Polyline.web.d.ts +6 -0
- package/lib/typescript/src/components/Polyline.web.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/components/index.web.d.ts +5 -0
- package/lib/typescript/src/components/index.web.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 +5 -6
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/index.web.d.ts +7 -0
- package/lib/typescript/src/index.web.d.ts.map +1 -0
- package/package.json +20 -7
- 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/MapProvider.tsx +10 -0
- package/src/MapProvider.types.ts +16 -0
- package/src/MapProvider.web.tsx +6 -0
- package/src/MapView.tsx +27 -10
- package/src/MapView.types.ts +24 -15
- package/src/MapView.web.tsx +319 -0
- package/src/components/Marker.tsx +63 -0
- package/src/components/Marker.web.tsx +32 -0
- package/src/components/Polyline.tsx +57 -0
- package/src/components/Polyline.web.tsx +222 -0
- package/src/components/index.ts +2 -0
- package/src/components/index.web.ts +4 -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 +11 -7
- package/src/index.web.ts +17 -0
- 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.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.tsx +0 -32
- package/src/Polyline.types.ts +0 -24
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
#import "
|
|
2
|
-
#import "
|
|
3
|
-
#import "
|
|
4
|
-
#import "
|
|
1
|
+
#import "LuggAppleMapView.h"
|
|
2
|
+
#import "LuggMapWrapperView.h"
|
|
3
|
+
#import "LuggMarkerView.h"
|
|
4
|
+
#import "LuggPolylineView.h"
|
|
5
5
|
#import "core/MKPolylineAnimator.h"
|
|
6
6
|
#import "events/CameraIdleEvent.h"
|
|
7
7
|
#import "events/CameraMoveEvent.h"
|
|
8
|
+
#import "events/ReadyEvent.h"
|
|
8
9
|
#import "extensions/MKMapView+Zoom.h"
|
|
9
10
|
|
|
10
11
|
#import <react/renderer/components/RNMapsSpec/ComponentDescriptors.h>
|
|
@@ -21,36 +22,39 @@ using namespace luggmaps::events;
|
|
|
21
22
|
@property(nonatomic, assign) CLLocationCoordinate2D coordinate;
|
|
22
23
|
@property(nonatomic, copy, nullable) NSString *title;
|
|
23
24
|
@property(nonatomic, copy, nullable) NSString *subtitle;
|
|
24
|
-
@property(nonatomic, strong)
|
|
25
|
+
@property(nonatomic, strong) LuggMarkerView *markerView;
|
|
25
26
|
@property(nonatomic, weak) MKAnnotationView *annotationView;
|
|
26
27
|
@end
|
|
27
28
|
|
|
28
29
|
@implementation AppleMarkerAnnotation
|
|
29
30
|
@end
|
|
30
31
|
|
|
31
|
-
@implementation
|
|
32
|
+
@implementation LuggAppleMapViewContent
|
|
32
33
|
@end
|
|
33
34
|
|
|
34
|
-
@interface
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
@interface LuggAppleMapView () <RCTLuggAppleMapViewViewProtocol,
|
|
36
|
+
MKMapViewDelegate, LuggMarkerViewDelegate,
|
|
37
|
+
LuggPolylineViewDelegate>
|
|
37
38
|
@end
|
|
38
39
|
|
|
39
|
-
@implementation
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
@implementation LuggAppleMapView {
|
|
41
|
+
LuggAppleMapViewContent *_mapView;
|
|
42
|
+
LuggMapWrapperView *_mapWrapperView;
|
|
43
|
+
BOOL _isMapReady;
|
|
42
44
|
BOOL _isDragging;
|
|
45
|
+
double _minZoom;
|
|
46
|
+
double _maxZoom;
|
|
43
47
|
}
|
|
44
48
|
|
|
45
49
|
+ (ComponentDescriptorProvider)componentDescriptorProvider {
|
|
46
50
|
return concreteComponentDescriptorProvider<
|
|
47
|
-
|
|
51
|
+
LuggAppleMapViewComponentDescriptor>();
|
|
48
52
|
}
|
|
49
53
|
|
|
50
54
|
- (instancetype)initWithFrame:(CGRect)frame {
|
|
51
55
|
if (self = [super initWithFrame:frame]) {
|
|
52
56
|
static const auto defaultProps =
|
|
53
|
-
std::make_shared<const
|
|
57
|
+
std::make_shared<const LuggAppleMapViewProps>();
|
|
54
58
|
_props = defaultProps;
|
|
55
59
|
}
|
|
56
60
|
|
|
@@ -64,10 +68,10 @@ using namespace luggmaps::events;
|
|
|
64
68
|
index:(NSInteger)index {
|
|
65
69
|
[super mountChildComponentView:childComponentView index:index];
|
|
66
70
|
|
|
67
|
-
if ([childComponentView isKindOfClass:[
|
|
68
|
-
_mapWrapperView = (
|
|
69
|
-
} else if ([childComponentView isKindOfClass:[
|
|
70
|
-
|
|
71
|
+
if ([childComponentView isKindOfClass:[LuggMapWrapperView class]]) {
|
|
72
|
+
_mapWrapperView = (LuggMapWrapperView *)childComponentView;
|
|
73
|
+
} else if ([childComponentView isKindOfClass:[LuggMarkerView class]]) {
|
|
74
|
+
LuggMarkerView *markerView = (LuggMarkerView *)childComponentView;
|
|
71
75
|
markerView.delegate = self;
|
|
72
76
|
|
|
73
77
|
AppleMarkerAnnotation *annotation = [[AppleMarkerAnnotation alloc] init];
|
|
@@ -79,9 +83,8 @@ using namespace luggmaps::events;
|
|
|
79
83
|
}
|
|
80
84
|
|
|
81
85
|
[self markerViewDidUpdate:markerView];
|
|
82
|
-
} else if ([childComponentView isKindOfClass:[
|
|
83
|
-
|
|
84
|
-
(LuggMapsPolylineView *)childComponentView;
|
|
86
|
+
} else if ([childComponentView isKindOfClass:[LuggPolylineView class]]) {
|
|
87
|
+
LuggPolylineView *polylineView = (LuggPolylineView *)childComponentView;
|
|
85
88
|
polylineView.delegate = self;
|
|
86
89
|
[self addPolylineViewToMap:polylineView];
|
|
87
90
|
}
|
|
@@ -90,8 +93,8 @@ using namespace luggmaps::events;
|
|
|
90
93
|
- (void)unmountChildComponentView:
|
|
91
94
|
(UIView<RCTComponentViewProtocol> *)childComponentView
|
|
92
95
|
index:(NSInteger)index {
|
|
93
|
-
if ([childComponentView isKindOfClass:[
|
|
94
|
-
|
|
96
|
+
if ([childComponentView isKindOfClass:[LuggMarkerView class]]) {
|
|
97
|
+
LuggMarkerView *markerView = (LuggMarkerView *)childComponentView;
|
|
95
98
|
markerView.delegate = nil;
|
|
96
99
|
|
|
97
100
|
AppleMarkerAnnotation *annotation =
|
|
@@ -103,9 +106,8 @@ using namespace luggmaps::events;
|
|
|
103
106
|
[_mapView removeAnnotation:annotation];
|
|
104
107
|
markerView.marker = nil;
|
|
105
108
|
}
|
|
106
|
-
} else if ([childComponentView isKindOfClass:[
|
|
107
|
-
|
|
108
|
-
(LuggMapsPolylineView *)childComponentView;
|
|
109
|
+
} else if ([childComponentView isKindOfClass:[LuggPolylineView class]]) {
|
|
110
|
+
LuggPolylineView *polylineView = (LuggPolylineView *)childComponentView;
|
|
109
111
|
polylineView.delegate = nil;
|
|
110
112
|
MKPolyline *polyline = (MKPolyline *)polylineView.polyline;
|
|
111
113
|
if (polyline) {
|
|
@@ -130,6 +132,7 @@ using namespace luggmaps::events;
|
|
|
130
132
|
[_mapView removeFromSuperview];
|
|
131
133
|
_mapView = nil;
|
|
132
134
|
_mapWrapperView = nil;
|
|
135
|
+
_isMapReady = NO;
|
|
133
136
|
}
|
|
134
137
|
|
|
135
138
|
#pragma mark - Map Initialization
|
|
@@ -140,10 +143,10 @@ using namespace luggmaps::events;
|
|
|
140
143
|
}
|
|
141
144
|
|
|
142
145
|
const auto &viewProps =
|
|
143
|
-
*std::static_pointer_cast<
|
|
146
|
+
*std::static_pointer_cast<LuggAppleMapViewProps const>(_props);
|
|
144
147
|
|
|
145
|
-
_mapView =
|
|
146
|
-
initWithFrame:_mapWrapperView.bounds];
|
|
148
|
+
_mapView =
|
|
149
|
+
[[LuggAppleMapViewContent alloc] initWithFrame:_mapWrapperView.bounds];
|
|
147
150
|
_mapView.autoresizingMask =
|
|
148
151
|
UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
|
149
152
|
_mapView.delegate = self;
|
|
@@ -152,6 +155,15 @@ using namespace luggmaps::events;
|
|
|
152
155
|
_mapView.scrollEnabled = viewProps.scrollEnabled;
|
|
153
156
|
_mapView.rotateEnabled = viewProps.rotateEnabled;
|
|
154
157
|
_mapView.pitchEnabled = viewProps.pitchEnabled;
|
|
158
|
+
_mapView.showsUserLocation = viewProps.userLocationEnabled;
|
|
159
|
+
|
|
160
|
+
_minZoom = viewProps.minZoom;
|
|
161
|
+
_maxZoom = viewProps.maxZoom;
|
|
162
|
+
[self applyZoomRange];
|
|
163
|
+
|
|
164
|
+
_mapView.layoutMargins =
|
|
165
|
+
UIEdgeInsetsMake(viewProps.padding.top, viewProps.padding.left,
|
|
166
|
+
viewProps.padding.bottom, viewProps.padding.right);
|
|
155
167
|
|
|
156
168
|
[_mapWrapperView addSubview:_mapView];
|
|
157
169
|
|
|
@@ -162,18 +174,22 @@ using namespace luggmaps::events;
|
|
|
162
174
|
|
|
163
175
|
// Add annotations for any markers that were mounted before map was ready
|
|
164
176
|
for (UIView *subview in self.subviews) {
|
|
165
|
-
if ([subview isKindOfClass:[
|
|
166
|
-
|
|
177
|
+
if ([subview isKindOfClass:[LuggMarkerView class]]) {
|
|
178
|
+
LuggMarkerView *markerView = (LuggMarkerView *)subview;
|
|
167
179
|
AppleMarkerAnnotation *annotation =
|
|
168
180
|
(AppleMarkerAnnotation *)markerView.marker;
|
|
169
181
|
if (annotation) {
|
|
170
182
|
[_mapView addAnnotation:annotation];
|
|
171
183
|
}
|
|
172
|
-
} else if ([subview isKindOfClass:[
|
|
173
|
-
|
|
184
|
+
} else if ([subview isKindOfClass:[LuggPolylineView class]]) {
|
|
185
|
+
LuggPolylineView *polylineView = (LuggPolylineView *)subview;
|
|
174
186
|
[self addPolylineViewToMap:polylineView];
|
|
175
187
|
}
|
|
176
188
|
}
|
|
189
|
+
|
|
190
|
+
_isMapReady = YES;
|
|
191
|
+
|
|
192
|
+
ReadyEvent::emit<LuggAppleMapViewEventEmitter>(_eventEmitter);
|
|
177
193
|
}
|
|
178
194
|
|
|
179
195
|
- (void)setCameraWithLatitude:(double)latitude
|
|
@@ -185,6 +201,27 @@ using namespace luggmaps::events;
|
|
|
185
201
|
[_mapView setCenterCoordinate:center zoomLevel:zoom animated:animated];
|
|
186
202
|
}
|
|
187
203
|
|
|
204
|
+
- (CLLocationDistance)cameraDistanceForZoomLevel:(double)zoomLevel {
|
|
205
|
+
// Approximate conversion: at zoom 0, altitude ~128M km
|
|
206
|
+
// Each zoom level halves the altitude
|
|
207
|
+
return 128000000.0 / pow(2, zoomLevel);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
- (void)applyZoomRange {
|
|
211
|
+
if (!_mapView)
|
|
212
|
+
return;
|
|
213
|
+
|
|
214
|
+
CLLocationDistance minDistance =
|
|
215
|
+
_maxZoom > 0 ? [self cameraDistanceForZoomLevel:_maxZoom] : 0;
|
|
216
|
+
CLLocationDistance maxDistance =
|
|
217
|
+
_minZoom > 0 ? [self cameraDistanceForZoomLevel:_minZoom] : -1;
|
|
218
|
+
|
|
219
|
+
MKMapCameraZoomRange *zoomRange = [[MKMapCameraZoomRange alloc]
|
|
220
|
+
initWithMinCenterCoordinateDistance:minDistance
|
|
221
|
+
maxCenterCoordinateDistance:maxDistance];
|
|
222
|
+
_mapView.cameraZoomRange = zoomRange;
|
|
223
|
+
}
|
|
224
|
+
|
|
188
225
|
- (MKMapView *)mapView {
|
|
189
226
|
return _mapView;
|
|
190
227
|
}
|
|
@@ -194,16 +231,21 @@ using namespace luggmaps::events;
|
|
|
194
231
|
- (void)updateProps:(Props::Shared const &)props
|
|
195
232
|
oldProps:(Props::Shared const &)oldProps {
|
|
196
233
|
const auto &newViewProps =
|
|
197
|
-
*std::static_pointer_cast<
|
|
234
|
+
*std::static_pointer_cast<LuggAppleMapViewProps const>(props);
|
|
198
235
|
|
|
199
236
|
if (_mapView) {
|
|
200
237
|
_mapView.zoomEnabled = newViewProps.zoomEnabled;
|
|
201
238
|
_mapView.scrollEnabled = newViewProps.scrollEnabled;
|
|
202
239
|
_mapView.rotateEnabled = newViewProps.rotateEnabled;
|
|
203
240
|
_mapView.pitchEnabled = newViewProps.pitchEnabled;
|
|
241
|
+
_mapView.showsUserLocation = newViewProps.userLocationEnabled;
|
|
204
242
|
_mapView.layoutMargins = UIEdgeInsetsMake(
|
|
205
243
|
newViewProps.padding.top, newViewProps.padding.left,
|
|
206
244
|
newViewProps.padding.bottom, newViewProps.padding.right);
|
|
245
|
+
|
|
246
|
+
_minZoom = newViewProps.minZoom;
|
|
247
|
+
_maxZoom = newViewProps.maxZoom;
|
|
248
|
+
[self applyZoomRange];
|
|
207
249
|
}
|
|
208
250
|
|
|
209
251
|
[super updateProps:props oldProps:oldProps];
|
|
@@ -213,7 +255,7 @@ using namespace luggmaps::events;
|
|
|
213
255
|
|
|
214
256
|
- (void)updateAnnotationViewFrame:(AppleMarkerAnnotation *)annotation {
|
|
215
257
|
MKAnnotationView *annotationView = annotation.annotationView;
|
|
216
|
-
|
|
258
|
+
LuggMarkerView *markerView = annotation.markerView;
|
|
217
259
|
|
|
218
260
|
if (!annotationView || !markerView) {
|
|
219
261
|
return;
|
|
@@ -233,13 +275,13 @@ using namespace luggmaps::events;
|
|
|
233
275
|
|
|
234
276
|
#pragma mark - PolylineViewDelegate
|
|
235
277
|
|
|
236
|
-
- (void)polylineViewDidUpdate:(
|
|
278
|
+
- (void)polylineViewDidUpdate:(LuggPolylineView *)polylineView {
|
|
237
279
|
[self syncPolylineView:polylineView];
|
|
238
280
|
}
|
|
239
281
|
|
|
240
282
|
#pragma mark - Polyline Management
|
|
241
283
|
|
|
242
|
-
- (void)addPolylineViewToMap:(
|
|
284
|
+
- (void)addPolylineViewToMap:(LuggPolylineView *)polylineView {
|
|
243
285
|
if (!_mapView) {
|
|
244
286
|
return;
|
|
245
287
|
}
|
|
@@ -260,10 +302,10 @@ using namespace luggmaps::events;
|
|
|
260
302
|
free(coords);
|
|
261
303
|
|
|
262
304
|
polylineView.polyline = polyline;
|
|
263
|
-
[
|
|
305
|
+
[self insertOverlay:polyline withZIndex:polylineView.zIndex];
|
|
264
306
|
}
|
|
265
307
|
|
|
266
|
-
- (void)syncPolylineView:(
|
|
308
|
+
- (void)syncPolylineView:(LuggPolylineView *)polylineView {
|
|
267
309
|
if (!_mapView) {
|
|
268
310
|
return;
|
|
269
311
|
}
|
|
@@ -274,6 +316,9 @@ using namespace luggmaps::events;
|
|
|
274
316
|
// Build new polyline from coordinates
|
|
275
317
|
NSArray<CLLocation *> *coordinates = polylineView.coordinates;
|
|
276
318
|
if (coordinates.count == 0) {
|
|
319
|
+
if (renderer) {
|
|
320
|
+
renderer.animated = NO;
|
|
321
|
+
}
|
|
277
322
|
if (oldPolyline) {
|
|
278
323
|
[_mapView removeOverlay:oldPolyline];
|
|
279
324
|
polylineView.polyline = nil;
|
|
@@ -295,6 +340,8 @@ using namespace luggmaps::events;
|
|
|
295
340
|
|
|
296
341
|
// If we have an existing renderer, update it in place
|
|
297
342
|
if (renderer && oldPolyline) {
|
|
343
|
+
[_mapView removeOverlay:oldPolyline];
|
|
344
|
+
[self insertOverlay:newPolyline withZIndex:polylineView.zIndex];
|
|
298
345
|
[renderer updatePolyline:newPolyline];
|
|
299
346
|
renderer.lineWidth = polylineView.strokeWidth;
|
|
300
347
|
renderer.strokeColor = polylineView.strokeColors.firstObject;
|
|
@@ -308,13 +355,34 @@ using namespace luggmaps::events;
|
|
|
308
355
|
if (oldPolyline) {
|
|
309
356
|
[_mapView removeOverlay:oldPolyline];
|
|
310
357
|
}
|
|
311
|
-
[
|
|
358
|
+
[self insertOverlay:newPolyline withZIndex:polylineView.zIndex];
|
|
312
359
|
}
|
|
313
360
|
|
|
314
|
-
- (
|
|
361
|
+
- (void)insertOverlay:(id<MKOverlay>)overlay withZIndex:(NSInteger)zIndex {
|
|
362
|
+
if (zIndex == 0) {
|
|
363
|
+
[_mapView addOverlay:overlay];
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
NSArray<id<MKOverlay>> *overlays = _mapView.overlays;
|
|
368
|
+
NSInteger insertIndex = overlays.count;
|
|
369
|
+
|
|
370
|
+
for (NSInteger i = 0; i < overlays.count; i++) {
|
|
371
|
+
LuggPolylineView *existingPolylineView =
|
|
372
|
+
[self findPolylineViewForOverlay:overlays[i]];
|
|
373
|
+
if (existingPolylineView && existingPolylineView.zIndex > zIndex) {
|
|
374
|
+
insertIndex = i;
|
|
375
|
+
break;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
[_mapView insertOverlay:overlay atIndex:insertIndex];
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
- (LuggPolylineView *)findPolylineViewForOverlay:(id<MKOverlay>)overlay {
|
|
315
383
|
for (UIView *subview in self.subviews) {
|
|
316
|
-
if ([subview isKindOfClass:[
|
|
317
|
-
|
|
384
|
+
if ([subview isKindOfClass:[LuggPolylineView class]]) {
|
|
385
|
+
LuggPolylineView *polylineView = (LuggPolylineView *)subview;
|
|
318
386
|
if (polylineView.polyline == overlay) {
|
|
319
387
|
return polylineView;
|
|
320
388
|
}
|
|
@@ -325,7 +393,7 @@ using namespace luggmaps::events;
|
|
|
325
393
|
|
|
326
394
|
#pragma mark - MarkerViewDelegate
|
|
327
395
|
|
|
328
|
-
- (void)markerViewDidLayout:(
|
|
396
|
+
- (void)markerViewDidLayout:(LuggMarkerView *)markerView {
|
|
329
397
|
AppleMarkerAnnotation *annotation =
|
|
330
398
|
(AppleMarkerAnnotation *)markerView.marker;
|
|
331
399
|
if (annotation) {
|
|
@@ -333,7 +401,7 @@ using namespace luggmaps::events;
|
|
|
333
401
|
}
|
|
334
402
|
}
|
|
335
403
|
|
|
336
|
-
- (void)markerViewDidUpdate:(
|
|
404
|
+
- (void)markerViewDidUpdate:(LuggMarkerView *)markerView {
|
|
337
405
|
AppleMarkerAnnotation *annotation =
|
|
338
406
|
(AppleMarkerAnnotation *)markerView.marker;
|
|
339
407
|
|
|
@@ -346,6 +414,12 @@ using namespace luggmaps::events;
|
|
|
346
414
|
annotation.title = markerView.title;
|
|
347
415
|
annotation.subtitle = markerView.markerDescription;
|
|
348
416
|
|
|
417
|
+
MKAnnotationView *annotationView = annotation.annotationView;
|
|
418
|
+
if (annotationView) {
|
|
419
|
+
annotationView.layer.zPosition = markerView.zIndex;
|
|
420
|
+
annotationView.zPriority = markerView.zIndex;
|
|
421
|
+
}
|
|
422
|
+
|
|
349
423
|
[self updateAnnotationViewFrame:annotation];
|
|
350
424
|
}
|
|
351
425
|
|
|
@@ -367,27 +441,19 @@ using namespace luggmaps::events;
|
|
|
367
441
|
}
|
|
368
442
|
|
|
369
443
|
- (void)mapViewDidChangeVisibleRegion:(MKMapView *)mapView {
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
CameraMoveEvent{mapView.centerCoordinate.latitude,
|
|
375
|
-
mapView.centerCoordinate.longitude, mapView.zoomLevel,
|
|
376
|
-
_isDragging}
|
|
377
|
-
.emit(emitter);
|
|
378
|
-
}
|
|
444
|
+
CameraMoveEvent{mapView.centerCoordinate.latitude,
|
|
445
|
+
mapView.centerCoordinate.longitude, mapView.zoomLevel,
|
|
446
|
+
_isDragging}
|
|
447
|
+
.emit<LuggAppleMapViewEventEmitter>(_eventEmitter);
|
|
379
448
|
}
|
|
380
449
|
|
|
381
450
|
- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated {
|
|
451
|
+
BOOL wasDragging = _isDragging;
|
|
382
452
|
_isDragging = NO;
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
CameraIdleEvent{mapView.centerCoordinate.latitude,
|
|
388
|
-
mapView.centerCoordinate.longitude, mapView.zoomLevel}
|
|
389
|
-
.emit(emitter);
|
|
390
|
-
}
|
|
453
|
+
CameraIdleEvent{mapView.centerCoordinate.latitude,
|
|
454
|
+
mapView.centerCoordinate.longitude, mapView.zoomLevel,
|
|
455
|
+
static_cast<bool>(wasDragging)}
|
|
456
|
+
.emit<LuggAppleMapViewEventEmitter>(_eventEmitter);
|
|
391
457
|
}
|
|
392
458
|
|
|
393
459
|
- (MKAnnotationView *)mapView:(MKMapView *)mapView
|
|
@@ -397,7 +463,7 @@ using namespace luggmaps::events;
|
|
|
397
463
|
}
|
|
398
464
|
|
|
399
465
|
AppleMarkerAnnotation *markerAnnotation = (AppleMarkerAnnotation *)annotation;
|
|
400
|
-
|
|
466
|
+
LuggMarkerView *markerView = markerAnnotation.markerView;
|
|
401
467
|
|
|
402
468
|
if (!markerView || !markerView.hasCustomView) {
|
|
403
469
|
return nil;
|
|
@@ -408,7 +474,8 @@ using namespace luggmaps::events;
|
|
|
408
474
|
reuseIdentifier:nil];
|
|
409
475
|
annotationView.canShowCallout = YES;
|
|
410
476
|
annotationView.displayPriority = MKFeatureDisplayPriorityRequired;
|
|
411
|
-
annotationView.
|
|
477
|
+
annotationView.layer.zPosition = markerView.zIndex;
|
|
478
|
+
annotationView.zPriority = markerView.zIndex;
|
|
412
479
|
|
|
413
480
|
UIView *iconView = markerView.iconView;
|
|
414
481
|
[iconView removeFromSuperview];
|
|
@@ -435,8 +502,7 @@ using namespace luggmaps::events;
|
|
|
435
502
|
- (MKOverlayRenderer *)mapView:(MKMapView *)mapView
|
|
436
503
|
rendererForOverlay:(id<MKOverlay>)overlay {
|
|
437
504
|
if ([overlay isKindOfClass:[MKPolyline class]]) {
|
|
438
|
-
|
|
439
|
-
[self findPolylineViewForOverlay:overlay];
|
|
505
|
+
LuggPolylineView *polylineView = [self findPolylineViewForOverlay:overlay];
|
|
440
506
|
MKPolyline *polyline = (MKPolyline *)overlay;
|
|
441
507
|
|
|
442
508
|
if (polylineView) {
|
|
@@ -494,7 +560,10 @@ using namespace luggmaps::events;
|
|
|
494
560
|
}
|
|
495
561
|
|
|
496
562
|
- (void)fitCoordinates:(NSArray *)coordinates
|
|
497
|
-
|
|
563
|
+
paddingTop:(double)paddingTop
|
|
564
|
+
paddingLeft:(double)paddingLeft
|
|
565
|
+
paddingBottom:(double)paddingBottom
|
|
566
|
+
paddingRight:(double)paddingRight
|
|
498
567
|
duration:(double)duration {
|
|
499
568
|
if (!_mapView || coordinates.count == 0) {
|
|
500
569
|
return;
|
|
@@ -517,7 +586,7 @@ using namespace luggmaps::events;
|
|
|
517
586
|
free(coords);
|
|
518
587
|
|
|
519
588
|
UIEdgeInsets edgePadding =
|
|
520
|
-
UIEdgeInsetsMake(
|
|
589
|
+
UIEdgeInsetsMake(paddingTop, paddingLeft, paddingBottom, paddingRight);
|
|
521
590
|
|
|
522
591
|
if (duration < 0) {
|
|
523
592
|
[_mapView setVisibleMapRect:mapRect edgePadding:edgePadding animated:YES];
|
|
@@ -534,11 +603,11 @@ using namespace luggmaps::events;
|
|
|
534
603
|
}
|
|
535
604
|
|
|
536
605
|
- (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args {
|
|
537
|
-
|
|
606
|
+
RCTLuggAppleMapViewHandleCommand(self, commandName, args);
|
|
538
607
|
}
|
|
539
608
|
|
|
540
|
-
Class<RCTComponentViewProtocol>
|
|
541
|
-
return
|
|
609
|
+
Class<RCTComponentViewProtocol> LuggAppleMapViewCls(void) {
|
|
610
|
+
return LuggAppleMapView.class;
|
|
542
611
|
}
|
|
543
612
|
|
|
544
613
|
@end
|