@rnmapbox/maps 10.1.42 → 10.1.43-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ios/RNMBX/RNMBXCameraViewManager.m +3 -0
- package/ios/RNMBX/RNMBXCameraViewManager.swift +10 -8
- package/ios/RNMBX/RNMBXCircleLayerComponentView.mm +1 -1
- package/ios/RNMBX/RNMBXCircleLayerViewManager.m +2 -0
- package/ios/RNMBX/RNMBXCircleLayerViewManager.swift +2 -0
- package/ios/RNMBX/RNMBXMapViewManager.m +2 -0
- package/ios/RNMBX/RNMBXMapViewManager.swift +231 -177
- package/ios/RNMBX/RNMBXMapViewModule.h +3 -2
- package/ios/RNMBX/RNMBXMapViewModule.mm +10 -19
- package/ios/RNMBX/RNMBXShapeSourceViewManager.m +2 -0
- package/ios/RNMBX/RNMBXShapeSourceViewManager.swift +52 -47
- package/ios/RNMBX/ShapeAnimators/RNMBXMovePointShapeAnimatorModule.mm +2 -2
- package/ios/RNMBX/ShapeAnimators/RNMBXMovePointShapeAnimatorModule.swift +1 -1
- package/ios/RNMBX/Utils/RNMBXViewResolver.h +45 -0
- package/ios/RNMBX/Utils/RNMBXViewResolver.mm +134 -0
- package/lib/commonjs/components/Images.js +1 -1
- package/lib/commonjs/components/Images.js.map +1 -1
- package/lib/commonjs/components/MapView.js +5 -3
- package/lib/commonjs/components/MapView.js.map +1 -1
- package/lib/module/components/Images.js +1 -1
- package/lib/module/components/Images.js.map +1 -1
- package/lib/module/components/MapView.js +4 -2
- package/lib/module/components/MapView.js.map +1 -1
- package/package.json +133 -2
- package/rnmapbox-maps.podspec +2 -1
- package/src/components/Images.tsx +1 -1
- package/src/components/MapView.tsx +2 -2
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
#if !RCT_NEW_ARCH_ENABLED
|
|
2
|
+
|
|
1
3
|
#import "React/RCTBridgeModule.h"
|
|
2
4
|
#import <React/RCTViewManager.h>
|
|
3
5
|
#import <Foundation/Foundation.h>
|
|
@@ -22,3 +24,4 @@ RCT_EXPORT_VIEW_PROPERTY(onUserTrackingModeChange, RCTBubblingEventBlock)
|
|
|
22
24
|
RCT_EXPORT_VIEW_PROPERTY(stop, NSDictionary)
|
|
23
25
|
|
|
24
26
|
@end
|
|
27
|
+
#endif
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
1
|
+
#if !RCT_NEW_ARCH_ENABLED
|
|
2
|
+
import Foundation
|
|
3
|
+
import MapboxMaps
|
|
3
4
|
|
|
4
|
-
@objc(RNMBXCameraViewManager)
|
|
5
|
-
class RNMBXCameraViewManager
|
|
5
|
+
@objc(RNMBXCameraViewManager)
|
|
6
|
+
class RNMBXCameraViewManager: RCTViewManager {
|
|
6
7
|
@objc
|
|
7
8
|
override static func requiresMainQueueSetup() -> Bool {
|
|
8
|
-
|
|
9
|
+
return false
|
|
9
10
|
}
|
|
10
|
-
|
|
11
|
+
|
|
11
12
|
override func view() -> UIView! {
|
|
12
|
-
|
|
13
|
+
return RNMBXCamera()
|
|
13
14
|
}
|
|
14
|
-
}
|
|
15
|
+
}
|
|
16
|
+
#endif
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#if !RCT_NEW_ARCH_ENABLED
|
|
1
2
|
#import <React/RCTBridgeModule.h>
|
|
2
3
|
#import <React/RCTViewManager.h>
|
|
3
4
|
|
|
@@ -41,3 +42,4 @@ RCT_REMAP_VIEW_PROPERTY(onMapChange, reactOnMapChange, RCTBubblingEventBlock)
|
|
|
41
42
|
RCT_EXPORT_VIEW_PROPERTY(mapViewImpl, NSString)
|
|
42
43
|
|
|
43
44
|
@end
|
|
45
|
+
#endif
|
|
@@ -1,230 +1,284 @@
|
|
|
1
1
|
import MapboxMaps
|
|
2
2
|
|
|
3
3
|
#if RNMBX_11
|
|
4
|
-
extension QueriedSourceFeature {
|
|
5
|
-
|
|
6
|
-
}
|
|
4
|
+
extension QueriedSourceFeature {
|
|
5
|
+
var feature: Feature { return self.queriedFeature.feature }
|
|
6
|
+
}
|
|
7
7
|
#endif
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
#if !RCT_NEW_ARCH_ENABLED
|
|
10
|
+
|
|
11
|
+
@objc(RNMBXMapViewManager)
|
|
12
|
+
open class RNMBXMapViewManager: RCTViewManager {
|
|
11
13
|
@objc
|
|
12
14
|
override public static func requiresMainQueueSetup() -> Bool {
|
|
13
|
-
|
|
15
|
+
return false
|
|
14
16
|
}
|
|
15
|
-
|
|
17
|
+
|
|
16
18
|
func defaultFrame() -> CGRect {
|
|
17
|
-
|
|
19
|
+
return UIScreen.main.bounds
|
|
18
20
|
}
|
|
19
|
-
|
|
21
|
+
|
|
20
22
|
override open func view() -> UIView! {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
let result = RNMBXMapView(
|
|
24
|
+
frame: self.defaultFrame(), eventDispatcher: self.bridge.eventDispatcher())
|
|
25
|
+
return result
|
|
23
26
|
}
|
|
24
|
-
}
|
|
27
|
+
}
|
|
28
|
+
#else
|
|
29
|
+
@objc(RNMBXMapViewManager)
|
|
30
|
+
open class RNMBXMapViewManager: NSObject {
|
|
31
|
+
|
|
32
|
+
}
|
|
33
|
+
#endif
|
|
25
34
|
|
|
26
35
|
// MARK: - react methods
|
|
27
36
|
|
|
28
37
|
extension RNMBXMapViewManager {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
coordinates: [NSNumber],
|
|
38
|
-
resolver: @escaping RCTPromiseResolveBlock,
|
|
39
|
-
rejecter: @escaping RCTPromiseRejectBlock
|
|
40
|
-
) -> Void {
|
|
41
|
-
let result = view.queryTerrainElevation(coordinates: coordinates)
|
|
42
|
-
if let result = result {
|
|
43
|
-
resolver(["data": NSNumber(value: result)])
|
|
44
|
-
} else {
|
|
45
|
-
resolver(nil)
|
|
46
|
-
}
|
|
47
|
-
}
|
|
38
|
+
@objc public static func takeSnap(
|
|
39
|
+
_ view: RNMBXMapView,
|
|
40
|
+
writeToDisk: Bool,
|
|
41
|
+
resolver: @escaping RCTPromiseResolveBlock
|
|
42
|
+
) {
|
|
43
|
+
let uri = view.takeSnap(writeToDisk: writeToDisk)
|
|
44
|
+
resolver(["uri": uri.absoluteString])
|
|
45
|
+
}
|
|
48
46
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
47
|
+
@objc public static func queryTerrainElevation(
|
|
48
|
+
_ view: RNMBXMapView,
|
|
49
|
+
coordinates: [NSNumber],
|
|
50
|
+
resolver: @escaping RCTPromiseResolveBlock,
|
|
51
|
+
rejecter: @escaping RCTPromiseRejectBlock
|
|
52
|
+
) {
|
|
53
|
+
let result = view.queryTerrainElevation(coordinates: coordinates)
|
|
54
|
+
if let result = result {
|
|
55
|
+
resolver(["data": NSNumber(value: result)])
|
|
56
|
+
} else {
|
|
57
|
+
resolver(nil)
|
|
57
58
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@objc public static func setSourceVisibility(
|
|
62
|
+
_ view: RNMBXMapView,
|
|
63
|
+
visible: Bool,
|
|
64
|
+
sourceId: String,
|
|
65
|
+
sourceLayerId: String?,
|
|
66
|
+
resolver: @escaping RCTPromiseResolveBlock,
|
|
67
|
+
rejecter: @escaping RCTPromiseRejectBlock
|
|
68
|
+
) {
|
|
69
|
+
view.setSourceVisibility(visible, sourceId: sourceId, sourceLayerId: sourceLayerId)
|
|
70
|
+
resolver(nil)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@objc public static func getCenter(
|
|
74
|
+
_ view: RNMBXMapView, resolver: @escaping RCTPromiseResolveBlock,
|
|
75
|
+
rejecter: @escaping RCTPromiseRejectBlock
|
|
76
|
+
) {
|
|
77
|
+
view.withMapboxMap { map in
|
|
78
|
+
resolver([
|
|
79
|
+
"center": [
|
|
80
|
+
map.cameraState.center.longitude,
|
|
81
|
+
map.cameraState.center.latitude,
|
|
82
|
+
]
|
|
83
|
+
])
|
|
66
84
|
}
|
|
85
|
+
}
|
|
67
86
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
87
|
+
@objc public static func getCoordinateFromView(
|
|
88
|
+
_ view: RNMBXMapView,
|
|
89
|
+
atPoint point: CGPoint,
|
|
90
|
+
resolver: @escaping RCTPromiseResolveBlock,
|
|
91
|
+
rejecter: @escaping RCTPromiseRejectBlock
|
|
92
|
+
) {
|
|
93
|
+
view.withMapboxMap { map in
|
|
94
|
+
let coordinates = map.coordinate(for: point)
|
|
95
|
+
resolver(["coordinateFromView": [coordinates.longitude, coordinates.latitude]])
|
|
78
96
|
}
|
|
79
97
|
|
|
80
|
-
|
|
81
|
-
_ view: RNMBXMapView,
|
|
82
|
-
atCoordinate coordinate: [NSNumber],
|
|
83
|
-
resolver: @escaping RCTPromiseResolveBlock,
|
|
84
|
-
rejecter: @escaping RCTPromiseRejectBlock) {
|
|
85
|
-
view.withMapboxMap { map in
|
|
86
|
-
let coordinate = CLLocationCoordinate2DMake(coordinate[1].doubleValue, coordinate[0].doubleValue)
|
|
87
|
-
let point = map.point(for: coordinate)
|
|
88
|
-
resolver(["pointInView": [(point.x), (point.y)]])
|
|
89
|
-
}
|
|
90
|
-
}
|
|
98
|
+
}
|
|
91
99
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
@objc public static func getPointInView(
|
|
101
|
+
_ view: RNMBXMapView,
|
|
102
|
+
atCoordinate coordinate: [NSNumber],
|
|
103
|
+
resolver: @escaping RCTPromiseResolveBlock,
|
|
104
|
+
rejecter: @escaping RCTPromiseRejectBlock
|
|
105
|
+
) {
|
|
106
|
+
view.withMapboxMap { map in
|
|
107
|
+
let coordinate = CLLocationCoordinate2DMake(
|
|
108
|
+
coordinate[1].doubleValue, coordinate[0].doubleValue)
|
|
109
|
+
let point = map.point(for: coordinate)
|
|
110
|
+
resolver(["pointInView": [(point.x), (point.y)]])
|
|
111
|
+
}
|
|
112
|
+
}
|
|
102
113
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
114
|
+
@objc public static func setHandledMapChangedEvents(
|
|
115
|
+
_ view: RNMBXMapView,
|
|
116
|
+
events: [String],
|
|
117
|
+
resolver: @escaping RCTPromiseResolveBlock,
|
|
118
|
+
rejecter: @escaping RCTPromiseRejectBlock
|
|
119
|
+
) {
|
|
120
|
+
view.handleMapChangedEvents = Set(
|
|
121
|
+
events.compactMap {
|
|
122
|
+
RNMBXEvent.EventType(rawValue: $0)
|
|
123
|
+
})
|
|
124
|
+
resolver(nil)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
@objc public static func getZoom(
|
|
128
|
+
_ view: RNMBXMapView,
|
|
129
|
+
resolver: @escaping RCTPromiseResolveBlock,
|
|
130
|
+
rejecter: @escaping RCTPromiseRejectBlock
|
|
131
|
+
) {
|
|
132
|
+
view.withMapboxMap { map in
|
|
133
|
+
resolver(["zoom": map.cameraState.zoom])
|
|
110
134
|
}
|
|
135
|
+
}
|
|
111
136
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
137
|
+
@objc public static func getVisibleBounds(
|
|
138
|
+
_ view: RNMBXMapView,
|
|
139
|
+
resolver: @escaping RCTPromiseResolveBlock,
|
|
140
|
+
rejecter: @escaping RCTPromiseRejectBlock
|
|
141
|
+
) {
|
|
142
|
+
view.withMapboxMap { map in
|
|
143
|
+
resolver(["visibleBounds": map.coordinateBounds(for: view.bounds).toArray()])
|
|
119
144
|
}
|
|
145
|
+
}
|
|
120
146
|
|
|
121
147
|
}
|
|
122
148
|
|
|
123
149
|
// MARK: - queryRenderedFeatures
|
|
124
150
|
|
|
125
151
|
extension RNMBXMapViewManager {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
152
|
+
@objc public static func queryRenderedFeaturesAtPoint(
|
|
153
|
+
_ view: RNMBXMapView,
|
|
154
|
+
atPoint point: [NSNumber],
|
|
155
|
+
withFilter filter: [Any]?,
|
|
156
|
+
withLayerIDs layerIDs: [String]?,
|
|
157
|
+
resolver: @escaping RCTPromiseResolveBlock,
|
|
158
|
+
rejecter: @escaping RCTPromiseRejectBlock
|
|
159
|
+
) {
|
|
160
|
+
view.withMapboxMap { map in
|
|
161
|
+
let point = CGPoint(x: CGFloat(point[0].floatValue), y: CGFloat(point[1].floatValue))
|
|
162
|
+
|
|
163
|
+
logged("queryRenderedFeaturesAtPoint.option", rejecter: rejecter) {
|
|
164
|
+
let options = try RenderedQueryOptions(
|
|
165
|
+
layerIds: (layerIDs ?? []).isEmpty ? nil : layerIDs, filter: filter?.asExpression())
|
|
166
|
+
|
|
167
|
+
map.queryRenderedFeatures(with: point, options: options) { result in
|
|
168
|
+
switch result {
|
|
169
|
+
case .success(let features):
|
|
170
|
+
resolver([
|
|
171
|
+
"data": [
|
|
172
|
+
"type": "FeatureCollection",
|
|
173
|
+
"features": features.compactMap { queriedFeature in
|
|
174
|
+
logged("queryRenderedFeaturesAtPoint.feature.toJSON") {
|
|
175
|
+
try queriedFeature.feature.toJSON()
|
|
149
176
|
}
|
|
150
|
-
}
|
|
151
|
-
|
|
177
|
+
},
|
|
178
|
+
]
|
|
179
|
+
])
|
|
180
|
+
case .failure(let error):
|
|
181
|
+
rejecter("queryRenderedFeaturesAtPoint", "failed to query features", error)
|
|
152
182
|
}
|
|
183
|
+
}
|
|
153
184
|
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
154
187
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
188
|
+
@objc public static func queryRenderedFeaturesInRect(
|
|
189
|
+
_ map: RNMBXMapView,
|
|
190
|
+
withBBox bbox: [NSNumber],
|
|
191
|
+
withFilter filter: [Any]?,
|
|
192
|
+
withLayerIDs layerIDs: [String]?,
|
|
193
|
+
resolver: @escaping RCTPromiseResolveBlock,
|
|
194
|
+
rejecter: @escaping RCTPromiseRejectBlock
|
|
195
|
+
) {
|
|
196
|
+
let top = bbox.isEmpty ? 0.0 : CGFloat(bbox[0].floatValue)
|
|
197
|
+
let right = bbox.isEmpty ? 0.0 : CGFloat(bbox[1].floatValue)
|
|
198
|
+
let bottom = bbox.isEmpty ? 0.0 : CGFloat(bbox[2].floatValue)
|
|
199
|
+
let left = bbox.isEmpty ? 0.0 : CGFloat(bbox[3].floatValue)
|
|
200
|
+
let rect =
|
|
201
|
+
bbox.isEmpty
|
|
202
|
+
? CGRect(x: 0.0, y: 0.0, width: map.bounds.size.width, height: map.bounds.size.height)
|
|
203
|
+
: CGRect(
|
|
204
|
+
x: [left, right].min()!, y: [top, bottom].min()!, width: abs(right - left),
|
|
205
|
+
height: abs(bottom - top))
|
|
206
|
+
logged("queryRenderedFeaturesInRect.option", rejecter: rejecter) {
|
|
207
|
+
let options = try RenderedQueryOptions(
|
|
208
|
+
layerIds: layerIDs?.isEmpty ?? true ? nil : layerIDs, filter: filter?.asExpression())
|
|
209
|
+
map.mapboxMap.queryRenderedFeatures(with: rect, options: options) { result in
|
|
210
|
+
switch result {
|
|
211
|
+
case .success(let features):
|
|
212
|
+
resolver([
|
|
213
|
+
"data": [
|
|
214
|
+
"type": "FeatureCollection",
|
|
215
|
+
"features": features.compactMap { queriedFeature in
|
|
216
|
+
logged("queryRenderedFeaturesInRect.queriedfeature.map") {
|
|
217
|
+
try queriedFeature.feature.toJSON()
|
|
179
218
|
}
|
|
180
|
-
}
|
|
181
|
-
|
|
219
|
+
},
|
|
220
|
+
]
|
|
221
|
+
])
|
|
222
|
+
case .failure(let error):
|
|
223
|
+
rejecter("queryRenderedFeaturesInRect", "failed to query features", error)
|
|
182
224
|
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
183
228
|
|
|
184
|
-
|
|
229
|
+
@objc public static func querySourceFeatures(
|
|
185
230
|
_ map: RNMBXMapView,
|
|
186
231
|
withSourceId sourceId: String,
|
|
187
232
|
withFilter filter: [Any]?,
|
|
188
233
|
withSourceLayerIds sourceLayerIds: [String]?,
|
|
189
234
|
resolver: @escaping RCTPromiseResolveBlock,
|
|
190
|
-
rejecter: @escaping RCTPromiseRejectBlock
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
235
|
+
rejecter: @escaping RCTPromiseRejectBlock
|
|
236
|
+
) {
|
|
237
|
+
let sourceLayerIds = sourceLayerIds?.isEmpty ?? true ? nil : sourceLayerIds
|
|
238
|
+
logged("querySourceFeatures.option", rejecter: rejecter) {
|
|
239
|
+
let options = SourceQueryOptions(
|
|
240
|
+
sourceLayerIds: sourceLayerIds, filter: filter ?? Exp(arguments: []))
|
|
241
|
+
map.mapboxMap.querySourceFeatures(for: sourceId, options: options) { result in
|
|
242
|
+
switch result {
|
|
243
|
+
case .success(let features):
|
|
244
|
+
resolver([
|
|
245
|
+
"data": [
|
|
246
|
+
"type": "FeatureCollection",
|
|
247
|
+
"features": features.compactMap { queriedFeature in
|
|
248
|
+
logged("querySourceFeatures.queriedfeature.map") {
|
|
249
|
+
try queriedFeature.feature.toJSON()
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
] as [String: Any]
|
|
253
|
+
])
|
|
254
|
+
case .failure(let error):
|
|
255
|
+
rejecter(
|
|
256
|
+
"querySourceFeatures",
|
|
257
|
+
"failed to query source features: \(error.localizedDescription)", error)
|
|
205
258
|
}
|
|
206
259
|
}
|
|
207
260
|
}
|
|
261
|
+
}
|
|
208
262
|
|
|
209
|
-
|
|
210
|
-
|
|
263
|
+
static func clearData(_ view: RNMBXMapView, completion: @escaping (Error?) -> Void) {
|
|
264
|
+
#if RNMBX_11
|
|
211
265
|
MapboxMap.clearData(completion: completion)
|
|
212
|
-
|
|
266
|
+
#else
|
|
213
267
|
view.mapboxMap.clearData(completion: completion)
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}
|
|
268
|
+
#endif
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
@objc public static func clearData(
|
|
272
|
+
_ mapView: RNMBXMapView,
|
|
273
|
+
resolver: @escaping RCTPromiseResolveBlock,
|
|
274
|
+
rejecter: @escaping RCTPromiseRejectBlock
|
|
275
|
+
) {
|
|
276
|
+
self.clearData(mapView) { error in
|
|
277
|
+
if let error = error {
|
|
278
|
+
rejecter("clearData", "failed to clearData: \(error.localizedDescription)", error)
|
|
279
|
+
} else {
|
|
280
|
+
resolver(nil)
|
|
281
|
+
}
|
|
229
282
|
}
|
|
283
|
+
}
|
|
230
284
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#import <Foundation/Foundation.h>
|
|
2
2
|
#import <UIKit/UIKit.h>
|
|
3
|
+
#import "RNMBXViewResolver.h"
|
|
3
4
|
|
|
4
5
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
5
6
|
#import "rnmapbox_maps_specs.h"
|
|
@@ -9,9 +10,9 @@
|
|
|
9
10
|
|
|
10
11
|
@interface RNMBXMapViewModule : NSObject
|
|
11
12
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
12
|
-
<NativeMapViewModuleSpec>
|
|
13
|
+
<NativeMapViewModuleSpec, RNMBXViewResolverDelegate>
|
|
13
14
|
#else
|
|
14
|
-
<RCTBridgeModule>
|
|
15
|
+
<RCTBridgeModule, RNMBXViewResolverDelegate>
|
|
15
16
|
#endif
|
|
16
17
|
|
|
17
18
|
@end
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
#endif // RCT_NEW_ARCH_ENABLED
|
|
9
9
|
|
|
10
10
|
#import "rnmapbox_maps-Swift.pre.h"
|
|
11
|
+
#import "RNMBXViewResolver.h"
|
|
11
12
|
|
|
12
13
|
@implementation RNMBXMapViewModule
|
|
13
14
|
|
|
@@ -27,26 +28,16 @@ RCT_EXPORT_MODULE();
|
|
|
27
28
|
|
|
28
29
|
- (void)withMapView:(nonnull NSNumber*)viewRef block:(void (^)(RNMBXMapView *))block reject:(RCTPromiseRejectBlock)reject methodName:(NSString *)methodName
|
|
29
30
|
{
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
39
|
-
RNMBXMapView *view = [uiManager viewForReactTag:viewRef];
|
|
40
|
-
#endif // RCT_NEW_ARCH_ENABLED
|
|
41
|
-
if (view != nil) {
|
|
42
|
-
block(view);
|
|
43
|
-
} else {
|
|
44
|
-
reject(methodName, [NSString stringWithFormat:@"Unknown reactTag: %@", viewRef], nil);
|
|
45
|
-
}
|
|
46
|
-
}];
|
|
31
|
+
[RNMBXViewResolver withViewRef:viewRef
|
|
32
|
+
delegate:self
|
|
33
|
+
expectedClass:[RNMBXMapView class]
|
|
34
|
+
block:^(UIView *view) {
|
|
35
|
+
block((RNMBXMapView *)view);
|
|
36
|
+
}
|
|
37
|
+
reject:reject
|
|
38
|
+
methodName:methodName];
|
|
47
39
|
}
|
|
48
40
|
|
|
49
|
-
|
|
50
41
|
RCT_EXPORT_METHOD(takeSnap:(nonnull NSNumber*)viewRef writeToDisk:(BOOL)writeToDisk resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
51
42
|
{
|
|
52
43
|
[self withMapView:viewRef block:^(RNMBXMapView *view) {
|
|
@@ -72,7 +63,7 @@ RCT_EXPORT_METHOD(getCoordinateFromView:(nonnull NSNumber*)viewRef atPoint:(NSAr
|
|
|
72
63
|
[self withMapView:viewRef block:^(RNMBXMapView *view) {
|
|
73
64
|
NSNumber* a = [atPoint objectAtIndex:0];
|
|
74
65
|
NSNumber* b = [atPoint objectAtIndex:1];
|
|
75
|
-
|
|
66
|
+
|
|
76
67
|
[RNMBXMapViewManager getCoordinateFromView:view atPoint:CGPointMake(a.floatValue, b.floatValue) resolver:resolve rejecter:reject];
|
|
77
68
|
} reject:reject methodName:@"getCoordinateFromView"];
|
|
78
69
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#if !RCT_NEW_ARCH_ENABLED
|
|
1
2
|
#import <React/RCTBridgeModule.h>
|
|
2
3
|
#import <React/RCTViewManager.h>
|
|
3
4
|
|
|
@@ -24,3 +25,4 @@ RCT_EXPORT_VIEW_PROPERTY(hitbox, NSDictionary)
|
|
|
24
25
|
RCT_REMAP_VIEW_PROPERTY(onMapboxShapeSourcePress, onPress, RCTBubblingEventBlock)
|
|
25
26
|
|
|
26
27
|
@end
|
|
28
|
+
#endif
|