@rnmapbox/maps 10.0.0-beta.46 → 10.0.0-beta.48
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/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/AbstractMapFeature.kt +23 -2
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/annotation/RCTMGLMarkerView.kt +3 -4
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/annotation/RCTMGLPointAnnotation.kt +2 -2
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/camera/RCTMGLCamera.kt +24 -29
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/camera/RCTMGLCameraManager.kt +16 -25
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/images/RCTMGLImages.kt +2 -0
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/location/RCTMGLNativeUserLocation.kt +2 -2
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/mapview/RCTMGLMapView.kt +245 -76
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/mapview/RCTMGLMapViewManager.kt +25 -2
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/atmosphere/RCTMGLAtmosphere.kt +2 -0
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTLayer.kt +2 -2
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLShapeSource.kt +4 -0
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTSource.kt +2 -3
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/terrain/RCTMGLTerrain.kt +2 -0
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/utils/ConvertUtils.java +1 -1
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/utils/LatLngBounds.kt +35 -0
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/utils/extensions/CoordinateBounds.kt +23 -0
- package/docs/MapView.md +2 -2
- package/docs/docs.json +5 -5
- package/ios/RCTMGL-v10/RCTMGLCamera.swift +60 -4
- package/ios/RCTMGL-v10/RCTMGLCameraManager.m +1 -0
- package/ios/RCTMGL-v10/RCTMGLMapView.swift +14 -26
- package/ios/RCTMGL-v10/RCTMGLMapViewManager.swift +9 -11
- package/ios/RCTMGL-v10/RCTMGLShapeSource.swift +29 -23
- package/ios/RCTMGL-v10/RCTMGLShapeSourceManager.m +3 -3
- package/ios/RCTMGL-v10/RCTMGLShapeSourceManager.swift +3 -3
- package/javascript/components/MapView.js +20 -15
- package/javascript/components/MarkerView.tsx +12 -1
- package/javascript/components/ShapeSource.tsx +3 -3
- package/javascript/components/SymbolLayer.tsx +1 -1
- package/package.json +1 -1
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/utils/LatLngBounds.java +0 -42
package/docs/docs.json
CHANGED
|
@@ -2733,14 +2733,14 @@
|
|
|
2733
2733
|
},
|
|
2734
2734
|
{
|
|
2735
2735
|
"name": "queryRenderedFeaturesInRect",
|
|
2736
|
-
"docblock": "Returns an array of rendered map features that intersect with the given rectangle,\nrestricted to the given style layers and filtered by the given predicate.\n\n@example\nthis._map.queryRenderedFeaturesInRect([30, 40, 20, 10], ['==', 'type', 'Point'], ['id1', 'id2'])\n\n@param {Array<Number>} bbox - A rectangle expressed in the map view’s coordinate system.\n@param {Array=} filter - A set of strings that correspond to the names of layers defined in the current style. Only the features contained in these layers are included in the returned array.\n@param {Array=} layerIDs - A array of layer id's to filter the features by\n@return {FeatureCollection}",
|
|
2736
|
+
"docblock": "Returns an array of rendered map features that intersect with the given rectangle,\nrestricted to the given style layers and filtered by the given predicate. In v10,\npassing an empty array will query the entire visible bounds of the map.\n\n@example\nthis._map.queryRenderedFeaturesInRect([30, 40, 20, 10], ['==', 'type', 'Point'], ['id1', 'id2'])\n\n@param {Array<Number>} bbox - A rectangle expressed in the map view’s coordinate system. For v10, this can be an empty array to query the visible map area.\n@param {Array=} filter - A set of strings that correspond to the names of layers defined in the current style. Only the features contained in these layers are included in the returned array.\n@param {Array=} layerIDs - A array of layer id's to filter the features by\n@return {FeatureCollection}",
|
|
2737
2737
|
"modifiers": [
|
|
2738
2738
|
"async"
|
|
2739
2739
|
],
|
|
2740
2740
|
"params": [
|
|
2741
2741
|
{
|
|
2742
2742
|
"name": "bbox",
|
|
2743
|
-
"description": "A rectangle expressed in the map view’s coordinate system.",
|
|
2743
|
+
"description": "A rectangle expressed in the map view’s coordinate system. For v10, this can be an empty array to query the visible map area.",
|
|
2744
2744
|
"type": {
|
|
2745
2745
|
"name": "Array"
|
|
2746
2746
|
},
|
|
@@ -2769,7 +2769,7 @@
|
|
|
2769
2769
|
"name": "FeatureCollection"
|
|
2770
2770
|
}
|
|
2771
2771
|
},
|
|
2772
|
-
"description": "Returns an array of rendered map features that intersect with the given rectangle,\nrestricted to the given style layers and filtered by the given predicate.",
|
|
2772
|
+
"description": "Returns an array of rendered map features that intersect with the given rectangle,\nrestricted to the given style layers and filtered by the given predicate. In v10,\npassing an empty array will query the entire visible bounds of the map.",
|
|
2773
2773
|
"examples": [
|
|
2774
2774
|
"\nthis._map.queryRenderedFeaturesInRect([30, 40, 20, 10], ['==', 'type', 'Point'], ['id1', 'id2'])\n\n"
|
|
2775
2775
|
]
|
|
@@ -3939,10 +3939,10 @@
|
|
|
3939
3939
|
"name": "Promise",
|
|
3940
3940
|
"elements": [
|
|
3941
3941
|
{
|
|
3942
|
-
"name": "
|
|
3942
|
+
"name": "number"
|
|
3943
3943
|
}
|
|
3944
3944
|
],
|
|
3945
|
-
"raw": "Promise<
|
|
3945
|
+
"raw": "Promise<number>"
|
|
3946
3946
|
}
|
|
3947
3947
|
},
|
|
3948
3948
|
"description": "Returns the zoom needed to expand the cluster.",
|
|
@@ -108,7 +108,8 @@ class RCTMGLCamera : RCTMGLMapComponentBase, LocationConsumer {
|
|
|
108
108
|
var cameraAnimator: BasicCameraAnimator?
|
|
109
109
|
let cameraUpdateQueue = CameraUpdateQueue()
|
|
110
110
|
|
|
111
|
-
//
|
|
111
|
+
// MARK: React properties
|
|
112
|
+
|
|
112
113
|
@objc var animationDuration: NSNumber?
|
|
113
114
|
@objc var animationMode: NSString?
|
|
114
115
|
@objc var defaultStop: [String: Any]?
|
|
@@ -137,16 +138,34 @@ class RCTMGLCamera : RCTMGLMapComponentBase, LocationConsumer {
|
|
|
137
138
|
_updateCameraFromTrackingMode()
|
|
138
139
|
}
|
|
139
140
|
}
|
|
140
|
-
@objc var maxZoomLevel: NSNumber?
|
|
141
|
-
|
|
141
|
+
@objc var maxZoomLevel: NSNumber? {
|
|
142
|
+
didSet { _updateMaxBounds() }
|
|
143
|
+
}
|
|
144
|
+
@objc var minZoomLevel: NSNumber? {
|
|
145
|
+
didSet { _updateMaxBounds() }
|
|
146
|
+
}
|
|
142
147
|
@objc var onUserTrackingModeChange: RCTBubblingEventBlock? = nil
|
|
143
148
|
@objc var stop: [String: Any]? {
|
|
144
149
|
didSet {
|
|
145
150
|
_updateCamera()
|
|
146
151
|
}
|
|
147
152
|
}
|
|
153
|
+
|
|
154
|
+
@objc var maxBounds: String? {
|
|
155
|
+
didSet {
|
|
156
|
+
if let maxBounds = maxBounds {
|
|
157
|
+
logged("RCTMGLCamera.maxBounds") {
|
|
158
|
+
maxBoundsFeature = try JSONDecoder().decode(FeatureCollection.self, from: maxBounds.data(using: .utf8)!)
|
|
159
|
+
}
|
|
160
|
+
} else {
|
|
161
|
+
maxBoundsFeature = nil
|
|
162
|
+
}
|
|
163
|
+
_updateMaxBounds()
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
var maxBoundsFeature : FeatureCollection? = nil
|
|
148
167
|
|
|
149
|
-
// Update methods
|
|
168
|
+
// MARK: Update methods
|
|
150
169
|
|
|
151
170
|
func _updateCameraFromJavascript() {
|
|
152
171
|
guard !followUserLocation else {
|
|
@@ -185,6 +204,43 @@ class RCTMGLCamera : RCTMGLMapComponentBase, LocationConsumer {
|
|
|
185
204
|
map.viewport.idle()
|
|
186
205
|
map.location.removeLocationConsumer(consumer: self)
|
|
187
206
|
}
|
|
207
|
+
|
|
208
|
+
func _toCoordinateBounds(_ bounds: FeatureCollection) throws -> CoordinateBounds {
|
|
209
|
+
guard bounds.features.count == 2 else {
|
|
210
|
+
throw RCTMGLError.paramError("Expected two Points in FeatureColletion")
|
|
211
|
+
}
|
|
212
|
+
let swFeature = bounds.features[0]
|
|
213
|
+
let neFeature = bounds.features[1]
|
|
214
|
+
|
|
215
|
+
guard case let .point(sw) = swFeature.geometry,
|
|
216
|
+
case let .point(ne) = neFeature.geometry else {
|
|
217
|
+
throw RCTMGLError.paramError("Expected two Points in FeatureColletion")
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return CoordinateBounds(southwest: sw.coordinates, northeast: ne.coordinates)
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
func _updateMaxBounds() {
|
|
224
|
+
withMapView { map in
|
|
225
|
+
var options = CameraBoundsOptions()
|
|
226
|
+
|
|
227
|
+
if let maxBounds = self.maxBoundsFeature {
|
|
228
|
+
logged("RCTMGLCamera._updateMaxBounds._toCoordinateBounds") {
|
|
229
|
+
options.bounds = try self._toCoordinateBounds(maxBounds)
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
if let minZoomLevel = self.minZoomLevel {
|
|
233
|
+
options.minZoom = minZoomLevel.CGFloat
|
|
234
|
+
}
|
|
235
|
+
if let maxZoomLevel = self.maxZoomLevel {
|
|
236
|
+
options.maxZoom = maxZoomLevel.CGFloat
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
logged("RCTMGLCamera._updateMaxBounds") {
|
|
240
|
+
try map.mapboxMap.setCameraBounds(with: options)
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
188
244
|
|
|
189
245
|
func _updateCameraFromTrackingMode() {
|
|
190
246
|
withMapView { map in
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
@interface RCT_EXTERN_MODULE(RCTMGLCameraManager, RCTViewManager)
|
|
6
6
|
|
|
7
|
+
RCT_EXPORT_VIEW_PROPERTY(maxBounds, NSString)
|
|
7
8
|
RCT_EXPORT_VIEW_PROPERTY(animationDuration, NSNumber)
|
|
8
9
|
RCT_EXPORT_VIEW_PROPERTY(animationMode, NSString)
|
|
9
10
|
RCT_EXPORT_VIEW_PROPERTY(defaultStop, NSDictionary)
|
|
@@ -188,15 +188,15 @@ open class RCTMGLMapView : MapView {
|
|
|
188
188
|
let glPosition = MapboxGLPosition(rawValue: position)
|
|
189
189
|
switch glPosition {
|
|
190
190
|
case .topLeft:
|
|
191
|
-
return .
|
|
191
|
+
return .topLeading
|
|
192
192
|
case .bottomRight:
|
|
193
|
-
return .
|
|
193
|
+
return .bottomTrailing
|
|
194
194
|
case .topRight:
|
|
195
|
-
return .
|
|
195
|
+
return .topTrailing
|
|
196
196
|
case .bottomLeft:
|
|
197
|
-
return .
|
|
197
|
+
return .bottomLeading
|
|
198
198
|
case .none:
|
|
199
|
-
return .
|
|
199
|
+
return .topLeading
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
|
|
@@ -231,7 +231,7 @@ open class RCTMGLMapView : MapView {
|
|
|
231
231
|
}
|
|
232
232
|
|
|
233
233
|
@objc func setReactRotateEnabled(_ value: Bool) {
|
|
234
|
-
self.mapView.gestures.options.
|
|
234
|
+
self.mapView.gestures.options.rotateEnabled = value
|
|
235
235
|
}
|
|
236
236
|
|
|
237
237
|
@objc func setReactPitchEnabled(_ value: Bool) {
|
|
@@ -251,20 +251,20 @@ open class RCTMGLMapView : MapView {
|
|
|
251
251
|
}
|
|
252
252
|
}
|
|
253
253
|
|
|
254
|
-
private func getOrnamentOptionsFromPosition(_ position: [String: Int]
|
|
254
|
+
private func getOrnamentOptionsFromPosition(_ position: [String: Int]) -> (position: OrnamentPosition, margins: CGPoint)? {
|
|
255
255
|
let left = position["left"]
|
|
256
256
|
let right = position["right"]
|
|
257
257
|
let top = position["top"]
|
|
258
258
|
let bottom = position["bottom"]
|
|
259
259
|
|
|
260
260
|
if let left = left, let top = top {
|
|
261
|
-
return (OrnamentPosition.
|
|
261
|
+
return (OrnamentPosition.topLeading, CGPoint(x: left, y: top))
|
|
262
262
|
} else if let right = right, let top = top {
|
|
263
|
-
return (OrnamentPosition.
|
|
263
|
+
return (OrnamentPosition.topTrailing, CGPoint(x: right, y: top))
|
|
264
264
|
} else if let bottom = bottom, let right = right {
|
|
265
|
-
return (OrnamentPosition.
|
|
265
|
+
return (OrnamentPosition.bottomTrailing, CGPoint(x: right, y: bottom))
|
|
266
266
|
} else if let bottom = bottom, let left = left {
|
|
267
|
-
return (OrnamentPosition.
|
|
267
|
+
return (OrnamentPosition.bottomLeading, CGPoint(x: left, y: bottom))
|
|
268
268
|
}
|
|
269
269
|
|
|
270
270
|
return nil
|
|
@@ -520,7 +520,7 @@ extension RCTMGLMapView: GestureManagerDelegate {
|
|
|
520
520
|
let options = RenderedQueryOptions(
|
|
521
521
|
layerIds: source.getLayerIDs(), filter: nil
|
|
522
522
|
)
|
|
523
|
-
self.mapboxMap.queryRenderedFeatures(
|
|
523
|
+
self.mapboxMap.queryRenderedFeatures(with: hitboxRect, options: options) {
|
|
524
524
|
result in
|
|
525
525
|
|
|
526
526
|
var newHits = hits
|
|
@@ -772,12 +772,6 @@ class PointAnnotationManager : AnnotationInteractionDelegate {
|
|
|
772
772
|
}
|
|
773
773
|
}
|
|
774
774
|
}
|
|
775
|
-
/*
|
|
776
|
-
|
|
777
|
-
let rctmglPointAnnotation = userInfo[RCTMGLPointAnnotation.key] as? WeakRef<RCTMGLPointAnnotation>,
|
|
778
|
-
let rctmglPointAnnotation = rctmglPointAnnotation.object {
|
|
779
|
-
rctmglPointAnnotation.didTap()
|
|
780
|
-
}*/
|
|
781
775
|
}
|
|
782
776
|
}
|
|
783
777
|
|
|
@@ -874,12 +868,6 @@ class PointAnnotationManager : AnnotationInteractionDelegate {
|
|
|
874
868
|
}
|
|
875
869
|
}
|
|
876
870
|
}
|
|
877
|
-
/*
|
|
878
|
-
|
|
879
|
-
let rctmglPointAnnotation = userInfo[RCTMGLPointAnnotation.key] as? WeakRef<RCTMGLPointAnnotation>,
|
|
880
|
-
let rctmglPointAnnotation = rctmglPointAnnotation.object {
|
|
881
|
-
rctmglPointAnnotation.didTap()
|
|
882
|
-
}*/
|
|
883
871
|
}
|
|
884
872
|
}
|
|
885
873
|
|
|
@@ -896,8 +884,8 @@ class PointAnnotationManager : AnnotationInteractionDelegate {
|
|
|
896
884
|
}
|
|
897
885
|
switch sender.state {
|
|
898
886
|
case .began:
|
|
899
|
-
|
|
900
|
-
|
|
887
|
+
mapFeatureQueryable.queryRenderedFeatures(
|
|
888
|
+
with: sender.location(in: sender.view),
|
|
901
889
|
options: options) { [weak self] (result) in
|
|
902
890
|
|
|
903
891
|
guard let self = self else { return }
|
|
@@ -190,7 +190,7 @@ extension RCTMGLMapViewManager {
|
|
|
190
190
|
logged("queryRenderedFeaturesAtPoint.option", rejecter: rejecter) {
|
|
191
191
|
let options = try RenderedQueryOptions(layerIds: layerIDs, filter: filter?.asExpression())
|
|
192
192
|
|
|
193
|
-
mapboxMap.queryRenderedFeatures(
|
|
193
|
+
mapboxMap.queryRenderedFeatures(with: point, options: options) { result in
|
|
194
194
|
switch result {
|
|
195
195
|
case .success(let features):
|
|
196
196
|
resolver([
|
|
@@ -214,17 +214,15 @@ extension RCTMGLMapViewManager {
|
|
|
214
214
|
withLayerIDs layerIDs: [String]?,
|
|
215
215
|
resolver: @escaping RCTPromiseResolveBlock,
|
|
216
216
|
rejecter: @escaping RCTPromiseRejectBlock) -> Void {
|
|
217
|
-
|
|
218
|
-
let left = CGFloat(bbox[0].floatValue)
|
|
219
|
-
let bottom = CGFloat(bbox[1].floatValue)
|
|
220
|
-
let right = CGFloat(bbox[2].floatValue)
|
|
221
|
-
let top = CGFloat(bbox[3].floatValue)
|
|
222
|
-
let rect = CGRect(x: [left,right].min()!, y: [bottom
|
|
223
|
-
|
|
217
|
+
withMapView(reactTag, name:"queryRenderedFeaturesInRect", rejecter: rejecter) { mapView in
|
|
218
|
+
let left = bbox.isEmpty ? 0.0 : CGFloat(bbox[0].floatValue)
|
|
219
|
+
let bottom = bbox.isEmpty ? 0.0 : CGFloat(bbox[1].floatValue)
|
|
220
|
+
let right = bbox.isEmpty ? 0.0 : CGFloat(bbox[2].floatValue)
|
|
221
|
+
let top = bbox.isEmpty ? 0.0 : CGFloat(bbox[3].floatValue)
|
|
222
|
+
let rect = bbox.isEmpty ? CGRect(x: 0.0, y: 0.0, width: mapView.bounds.size.width, height: mapView.bounds.size.height) : CGRect(x: [left,right].min()!, y: [top,bottom].min()!, width: abs(right-left), height: abs(bottom-top))
|
|
224
223
|
logged("queryRenderedFeaturesInRect.option", rejecter: rejecter) {
|
|
225
224
|
let options = try RenderedQueryOptions(layerIds: layerIDs, filter: filter?.asExpression())
|
|
226
|
-
|
|
227
|
-
mapboxMap.queryRenderedFeatures(in: rect, options: options) { result in
|
|
225
|
+
mapView.mapboxMap.queryRenderedFeatures(with: rect, options: options) { result in
|
|
228
226
|
switch result {
|
|
229
227
|
case .success(let features):
|
|
230
228
|
resolver([
|
|
@@ -233,7 +231,7 @@ extension RCTMGLMapViewManager {
|
|
|
233
231
|
}]
|
|
234
232
|
])
|
|
235
233
|
case .failure(let error):
|
|
236
|
-
rejecter("
|
|
234
|
+
rejecter("queryRenderedFeaturesInRect","failed to query features", error)
|
|
237
235
|
}
|
|
238
236
|
}
|
|
239
237
|
}
|
|
@@ -21,7 +21,19 @@ class RCTMGLShapeSource : RCTMGLSource {
|
|
|
21
21
|
|
|
22
22
|
@objc var cluster : NSNumber?
|
|
23
23
|
@objc var clusterRadius : NSNumber?
|
|
24
|
-
@objc var clusterMaxZoomLevel : NSNumber?
|
|
24
|
+
@objc var clusterMaxZoomLevel : NSNumber? {
|
|
25
|
+
didSet {
|
|
26
|
+
logged("RCTMGLShapeSource.clusterMaxZoomLevel") {
|
|
27
|
+
if let number = clusterMaxZoomLevel?.doubleValue {
|
|
28
|
+
doUpdate { (style) in
|
|
29
|
+
logged("RCTMGLShapeSource.doUpdate") {
|
|
30
|
+
try style.setSourceProperty(for: id, property: "clusterMaxZoom", value: number)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
25
37
|
@objc var clusterProperties : [String: [Any]]?;
|
|
26
38
|
|
|
27
39
|
@objc var maxZoomLevel : NSNumber?
|
|
@@ -192,7 +204,7 @@ extension RCTMGLShapeSource
|
|
|
192
204
|
extension RCTMGLShapeSource
|
|
193
205
|
{
|
|
194
206
|
func getClusterExpansionZoom(
|
|
195
|
-
_
|
|
207
|
+
_ featureJSON: String,
|
|
196
208
|
completion: @escaping (Result<Int, Error>) -> Void)
|
|
197
209
|
{
|
|
198
210
|
guard let mapView = map?.mapView else {
|
|
@@ -200,29 +212,23 @@ extension RCTMGLShapeSource
|
|
|
200
212
|
return
|
|
201
213
|
}
|
|
202
214
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
let
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
guard let value = features.value as? NSNumber else {
|
|
215
|
-
completion(.failure(RCTMGLError.failed("getClusterExpansionZoom: not a number")))
|
|
216
|
-
return
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
completion(.success(value.intValue))
|
|
220
|
-
case .failure(let error):
|
|
221
|
-
completion(.failure(error))
|
|
215
|
+
logged("RCTMGLShapeSource.getClusterExpansionZoom", rejecter: { (_,_,error) in
|
|
216
|
+
completion(.failure(error!))
|
|
217
|
+
}) {
|
|
218
|
+
let cluster : Feature = try parse(featureJSON);
|
|
219
|
+
|
|
220
|
+
mapView.mapboxMap.queryFeatureExtension(for: self.id, feature: cluster, extension: "supercluster", extensionField: "expansion-zoom") { result in
|
|
221
|
+
switch result {
|
|
222
|
+
case .success(let features):
|
|
223
|
+
guard let value = features.value as? NSNumber else {
|
|
224
|
+
completion(.failure(RCTMGLError.failed("getClusterExpansionZoom: not a number")))
|
|
225
|
+
return
|
|
222
226
|
}
|
|
227
|
+
|
|
228
|
+
completion(.success(value.intValue))
|
|
229
|
+
case .failure(let error):
|
|
230
|
+
completion(.failure(error))
|
|
223
231
|
}
|
|
224
|
-
case .failure(let error):
|
|
225
|
-
completion(.failure(error))
|
|
226
232
|
}
|
|
227
233
|
}
|
|
228
234
|
}
|
|
@@ -25,9 +25,9 @@ RCT_REMAP_VIEW_PROPERTY(onMapboxShapeSourcePress, onPress, RCTBubblingEventBlock
|
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
RCT_EXTERN_METHOD(getClusterExpansionZoom:(nonnull NSNumber*)reactTag
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
featureJSON:(nonnull NSString*)featureJSON
|
|
29
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
30
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
31
31
|
|
|
32
32
|
RCT_EXTERN_METHOD(getClusterLeaves:(nonnull NSNumber*)reactTag
|
|
33
33
|
featureJSON:(nonnull NSString*)featureJSON
|
|
@@ -38,12 +38,12 @@ extension RCTMGLShapeSourceManager {
|
|
|
38
38
|
extension RCTMGLShapeSourceManager {
|
|
39
39
|
@objc func getClusterExpansionZoom(
|
|
40
40
|
_ reactTag: NSNumber,
|
|
41
|
-
|
|
41
|
+
featureJSON: String,
|
|
42
42
|
resolver: @escaping RCTPromiseResolveBlock,
|
|
43
43
|
rejecter: @escaping RCTPromiseRejectBlock) -> Void
|
|
44
44
|
{
|
|
45
|
-
self.withShapeSource(reactTag, name:"
|
|
46
|
-
shapeSource.getClusterExpansionZoom(
|
|
45
|
+
self.withShapeSource(reactTag, name:"getCluster ExpansionZoom", rejecter: rejecter) { shapeSource in
|
|
46
|
+
shapeSource.getClusterExpansionZoom(featureJSON) { result in
|
|
47
47
|
switch result {
|
|
48
48
|
case .success(let zoom):
|
|
49
49
|
resolver([
|
|
@@ -495,33 +495,38 @@ class MapView extends NativeBridgeComponent(
|
|
|
495
495
|
|
|
496
496
|
/**
|
|
497
497
|
* Returns an array of rendered map features that intersect with the given rectangle,
|
|
498
|
-
* restricted to the given style layers and filtered by the given predicate.
|
|
498
|
+
* restricted to the given style layers and filtered by the given predicate. In v10,
|
|
499
|
+
* passing an empty array will query the entire visible bounds of the map.
|
|
499
500
|
*
|
|
500
501
|
* @example
|
|
501
502
|
* this._map.queryRenderedFeaturesInRect([30, 40, 20, 10], ['==', 'type', 'Point'], ['id1', 'id2'])
|
|
502
503
|
*
|
|
503
|
-
* @param {Array<Number>} bbox - A rectangle expressed in the map view’s coordinate system.
|
|
504
|
+
* @param {Array<Number>} bbox - A rectangle expressed in the map view’s coordinate system. For v10, this can be an empty array to query the visible map area.
|
|
504
505
|
* @param {Array=} filter - A set of strings that correspond to the names of layers defined in the current style. Only the features contained in these layers are included in the returned array.
|
|
505
506
|
* @param {Array=} layerIDs - A array of layer id's to filter the features by
|
|
506
507
|
* @return {FeatureCollection}
|
|
507
508
|
*/
|
|
508
509
|
async queryRenderedFeaturesInRect(bbox, filter = [], layerIDs = []) {
|
|
509
|
-
if (
|
|
510
|
-
|
|
511
|
-
|
|
510
|
+
if (
|
|
511
|
+
bbox != null &&
|
|
512
|
+
(bbox.length === 4 || (MapboxGL.MapboxV10 && bbox.length === 0))
|
|
513
|
+
) {
|
|
514
|
+
const res = await this._runNativeCommand(
|
|
515
|
+
'queryRenderedFeaturesInRect',
|
|
516
|
+
this._nativeRef,
|
|
517
|
+
[bbox, getFilter(filter), layerIDs],
|
|
512
518
|
);
|
|
513
|
-
}
|
|
514
|
-
const res = await this._runNativeCommand(
|
|
515
|
-
'queryRenderedFeaturesInRect',
|
|
516
|
-
this._nativeRef,
|
|
517
|
-
[bbox, getFilter(filter), layerIDs],
|
|
518
|
-
);
|
|
519
519
|
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
520
|
+
if (isAndroid()) {
|
|
521
|
+
return JSON.parse(res.data);
|
|
522
|
+
}
|
|
523
523
|
|
|
524
|
-
|
|
524
|
+
return res.data;
|
|
525
|
+
} else {
|
|
526
|
+
throw new Error(
|
|
527
|
+
'Must pass in a valid bounding box: [top, right, bottom, left]. An empty array [] is also acceptable in v10.',
|
|
528
|
+
);
|
|
529
|
+
}
|
|
525
530
|
}
|
|
526
531
|
|
|
527
532
|
/**
|
|
@@ -119,8 +119,19 @@ class MarkerView extends React.PureComponent<Props> {
|
|
|
119
119
|
anchor={anchor}
|
|
120
120
|
allowOverlap={this.props.allowOverlap}
|
|
121
121
|
isSelected={this.props.isSelected}
|
|
122
|
+
onTouchEnd={(e) => {
|
|
123
|
+
e.stopPropagation();
|
|
124
|
+
}}
|
|
122
125
|
>
|
|
123
|
-
<View
|
|
126
|
+
<View
|
|
127
|
+
style={{ flex: 0, alignSelf: 'flex-start' }}
|
|
128
|
+
onStartShouldSetResponder={(_event) => {
|
|
129
|
+
return true;
|
|
130
|
+
}}
|
|
131
|
+
onTouchEnd={(e) => {
|
|
132
|
+
e.stopPropagation();
|
|
133
|
+
}}
|
|
134
|
+
>
|
|
124
135
|
{this.props.children}
|
|
125
136
|
</View>
|
|
126
137
|
</RCTMGLMarkerView>
|
|
@@ -210,12 +210,12 @@ export class ShapeSource extends NativeBridgeComponent(
|
|
|
210
210
|
*/
|
|
211
211
|
async getClusterExpansionZoom(
|
|
212
212
|
feature: string | GeoJSON.Feature,
|
|
213
|
-
): Promise<
|
|
213
|
+
): Promise<number> {
|
|
214
214
|
if (typeof feature === 'number') {
|
|
215
215
|
console.warn(
|
|
216
216
|
'Using cluster_id is deprecated and will be removed from the future releases. Please use cluster as an argument instead.',
|
|
217
217
|
);
|
|
218
|
-
const res: { data:
|
|
218
|
+
const res: { data: number } = await this._runNativeCommand(
|
|
219
219
|
'getClusterExpansionZoomById',
|
|
220
220
|
this._nativeRef,
|
|
221
221
|
[feature],
|
|
@@ -223,7 +223,7 @@ export class ShapeSource extends NativeBridgeComponent(
|
|
|
223
223
|
return res.data;
|
|
224
224
|
}
|
|
225
225
|
|
|
226
|
-
const res: { data:
|
|
226
|
+
const res: { data: number } = await this._runNativeCommand(
|
|
227
227
|
'getClusterExpansionZoom',
|
|
228
228
|
this._nativeRef,
|
|
229
229
|
[JSON.stringify(feature)],
|
|
@@ -87,7 +87,7 @@ export class SymbolLayer extends AbstractLayer<Props, NativeTypeProps> {
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
React.Children.forEach(this.props.children, (child) => {
|
|
90
|
-
if (child
|
|
90
|
+
if (child !== undefined && 'type' in child && child.type === View) {
|
|
91
91
|
isSnapshot = true;
|
|
92
92
|
}
|
|
93
93
|
});
|
package/package.json
CHANGED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
package com.mapbox.rctmgl.utils;
|
|
2
|
-
|
|
3
|
-
import com.mapbox.geojson.Point;
|
|
4
|
-
import com.mapbox.maps.CoordinateBounds;
|
|
5
|
-
|
|
6
|
-
public class LatLngBounds {
|
|
7
|
-
public static LatLngBounds from(double bbox, double bbox1, double bbox2, double bbox3) {
|
|
8
|
-
return new LatLngBounds(bbox, bbox1, bbox2, bbox3);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
LatLng getSouthWest() {
|
|
12
|
-
return new LatLng(latSouth, lonWest);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
LatLng getNorthEast() {
|
|
16
|
-
return new LatLng(latNorth, lonEast);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
LatLng[] toLatLngs() {
|
|
20
|
-
return new LatLng[] {getNorthEast(), getSouthWest()};
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
double latNorth;
|
|
24
|
-
double lonEast;
|
|
25
|
-
double latSouth;
|
|
26
|
-
double lonWest;
|
|
27
|
-
|
|
28
|
-
LatLngBounds(double latNorth,double lonEast, double latSouth, double lonWest) {
|
|
29
|
-
this.latNorth = latNorth;
|
|
30
|
-
this.lonEast = lonEast;
|
|
31
|
-
this.latSouth = latSouth;
|
|
32
|
-
this.lonWest = lonWest;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
public CoordinateBounds toBounds() {
|
|
36
|
-
return new CoordinateBounds(
|
|
37
|
-
Point.fromLngLat(lonWest, latSouth),
|
|
38
|
-
Point.fromLngLat(lonEast, latNorth),
|
|
39
|
-
false
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
}
|