@rnmapbox/maps 10.0.0-beta.45 → 10.0.0-beta.47

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.
Files changed (29) hide show
  1. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/AbstractMapFeature.kt +23 -2
  2. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/annotation/RCTMGLMarkerView.kt +3 -4
  3. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/annotation/RCTMGLPointAnnotation.kt +2 -2
  4. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/camera/RCTMGLCamera.kt +19 -10
  5. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/camera/RCTMGLCameraManager.kt +16 -25
  6. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/images/RCTMGLImages.kt +2 -0
  7. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/location/RCTMGLNativeUserLocation.kt +2 -2
  8. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/mapview/RCTMGLMapView.kt +217 -69
  9. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/mapview/RCTMGLMapViewManager.kt +22 -2
  10. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/atmosphere/RCTMGLAtmosphere.kt +2 -0
  11. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTLayer.kt +2 -2
  12. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLShapeSource.kt +4 -0
  13. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTSource.kt +2 -3
  14. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/terrain/RCTMGLTerrain.kt +2 -0
  15. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/modules/CustomHttpHeaders.kt +38 -0
  16. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/modules/RCTMGLModule.kt +12 -1
  17. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/utils/LatLngBounds.kt +35 -0
  18. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/utils/extensions/CoordinateBounds.kt +23 -0
  19. package/docs/docs.json +2 -2
  20. package/ios/RCTMGL-v10/RCTMGLCamera.swift +37 -2
  21. package/ios/RCTMGL-v10/RCTMGLCameraManager.m +1 -0
  22. package/ios/RCTMGL-v10/RCTMGLMapView.swift +70 -9
  23. package/ios/RCTMGL-v10/RCTMGLShapeSource.swift +29 -23
  24. package/ios/RCTMGL-v10/RCTMGLShapeSourceManager.m +3 -3
  25. package/ios/RCTMGL-v10/RCTMGLShapeSourceManager.swift +3 -3
  26. package/javascript/components/MarkerView.tsx +15 -1
  27. package/javascript/components/ShapeSource.tsx +3 -3
  28. package/package.json +1 -1
  29. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/utils/LatLngBounds.java +0 -42
@@ -32,6 +32,7 @@ class RCTMGLAtmosphere(context: Context?) : AbstractSourceConsumer(context) {
32
32
  // endregion RCTLayer
33
33
 
34
34
  override fun addToMap(mapView: RCTMGLMapView) {
35
+ super.addToMap(mapView)
35
36
  mMap = mapView.getMapboxMap()
36
37
  val atmosphere = makeAtmosphere()
37
38
  mAtmosphere = atmosphere
@@ -42,6 +43,7 @@ class RCTMGLAtmosphere(context: Context?) : AbstractSourceConsumer(context) {
42
43
  override fun removeFromMap(mapView: RCTMGLMapView) {
43
44
  mapView.savedStyle?.let { it.removeTerrain() }
44
45
  mMap = null
46
+ super.removeFromMap(mapView)
45
47
  }
46
48
 
47
49
  fun makeAtmosphere(): Atmosphere {
@@ -42,7 +42,6 @@ abstract class RCTLayer<T : Layer?>(protected var mContext: Context) : AbstractS
42
42
  protected var mMap: MapboxMap? = null
43
43
  @JvmField
44
44
  protected var mLayer: T? = null
45
- protected var mMapView: RCTMGLMapView? = null
46
45
  protected var mHadFilter = false
47
46
 
48
47
  fun setSourceID(sourceID: String?) {
@@ -230,8 +229,8 @@ abstract class RCTLayer<T : Layer?>(protected var mContext: Context) : AbstractS
230
229
  }
231
230
 
232
231
  override fun addToMap(mapView: RCTMGLMapView) {
232
+ super.addToMap(mapView)
233
233
  mMap = mapView.getMapboxMap()
234
- mMapView = mapView
235
234
  if (style == null) return
236
235
  val existingLayer = getLayerAs(style, iD)
237
236
  if (existingLayer != null) {
@@ -251,6 +250,7 @@ abstract class RCTLayer<T : Layer?>(protected var mContext: Context) : AbstractS
251
250
  if (style != null) {
252
251
  style!!.removeStyleLayer(mLayer!!.layerId)
253
252
  }
253
+ super.removeFromMap(mapView)
254
254
  }
255
255
 
256
256
  // v10TOOD: adding anything seems to make getStyle null
@@ -77,6 +77,10 @@ class RCTMGLShapeSource(context: Context, private val mManager: RCTMGLShapeSourc
77
77
 
78
78
  fun setClusterMaxZoom(clusterMaxZoom: Long) {
79
79
  mClusterMaxZoom = clusterMaxZoom
80
+ if (mSource != null && mMapView != null && !mMapView!!.isDestroyed) {
81
+ val result = mMap!!.getStyle()!!
82
+ .setStyleSourceProperty(iD!!, "clusterMaxZoom", Value.valueOf(clusterMaxZoom))
83
+ }
80
84
  }
81
85
 
82
86
  fun setClusterProperties(clusterProperties: HashMap<String, Any>) {
@@ -24,8 +24,6 @@ import java.util.ArrayList
24
24
  import java.util.HashMap
25
25
 
26
26
  abstract class RCTSource<T : Source?>(context: Context?) : AbstractMapFeature(context) {
27
- @JvmField
28
- protected var mMapView: RCTMGLMapView? = null
29
27
  @JvmField
30
28
  protected var mMap: MapboxMap? = null
31
29
  var iD: String? = null
@@ -107,7 +105,7 @@ abstract class RCTSource<T : Source?>(context: Context?) : AbstractMapFeature(co
107
105
  }
108
106
 
109
107
  override fun addToMap(mapView: RCTMGLMapView) {
110
- mMapView = mapView
108
+ super.addToMap(mapView)
111
109
  mMap = mapView.getMapboxMap()
112
110
  mMap?.getStyle(object : Style.OnStyleLoaded {
113
111
  override fun onStyleLoaded(style: Style) {
@@ -149,6 +147,7 @@ abstract class RCTSource<T : Source?>(context: Context?) : AbstractMapFeature(co
149
147
  Logger.w(LOG_TAG, String.format("RCTSource.removeFromMap: %s - %s", mSource, ex.message), ex)
150
148
  }
151
149
  }
150
+ super.removeFromMap(mapView)
152
151
  }
153
152
 
154
153
  fun addLayer(childView: View?, childPosition: Int) {
@@ -36,6 +36,7 @@ class RCTMGLTerrain(context: Context?) : AbstractSourceConsumer(context) {
36
36
  }
37
37
 
38
38
  override fun addToMap(mapView: RCTMGLMapView) {
39
+ super.addToMap(mapView)
39
40
  mMap = mapView.getMapboxMap()
40
41
  val terrain = makeTerrain()
41
42
  mTerrain = terrain
@@ -46,6 +47,7 @@ class RCTMGLTerrain(context: Context?) : AbstractSourceConsumer(context) {
46
47
  override fun removeFromMap(mapView: RCTMGLMapView) {
47
48
  mapView.savedStyle?.let { it.removeTerrain() }
48
49
  mMap = null
50
+ super.removeFromMap(mapView)
49
51
  }
50
52
 
51
53
  fun makeTerrain(): Terrain {
@@ -0,0 +1,38 @@
1
+ package com.mapbox.rctmgl.modules
2
+
3
+ import com.mapbox.common.*
4
+
5
+ object CustomHttpHeaders : HttpServiceInterceptorInterface {
6
+ init {}
7
+
8
+ val map = mutableMapOf<String, String>()
9
+
10
+ fun addCustomHeader(headerName: String, headerValue: String) {
11
+ HttpServiceFactory.getInstance().setInterceptor(
12
+ this
13
+ )
14
+ }
15
+
16
+ fun removeCustomHeader(headerName: String) {
17
+ map.remove(headerName)
18
+ }
19
+
20
+ override fun onRequest(request: HttpRequest): HttpRequest {
21
+ for (entry in map.entries.iterator()) {
22
+ request.headers[entry.key] = entry.value
23
+ }
24
+ return request
25
+ }
26
+
27
+ override fun onDownload(download: DownloadOptions): DownloadOptions {
28
+ for (entry in map.entries.iterator()) {
29
+ download.request.headers[entry.key] = entry.value
30
+ }
31
+ return download
32
+ }
33
+
34
+ override fun onResponse(response: HttpResponse): HttpResponse {
35
+ return response
36
+ }
37
+ }
38
+
@@ -12,6 +12,7 @@ import com.mapbox.rctmgl.modules.RCTMGLOfflineModule
12
12
  import com.mapbox.rctmgl.modules.RCTMGLLocationModule
13
13
  import com.facebook.react.bridge.ReactMethod
14
14
  import com.facebook.react.common.MapBuilder
15
+ import com.mapbox.common.*
15
16
  import com.mapbox.maps.Style
16
17
  import com.mapbox.rctmgl.components.camera.constants.CameraMode
17
18
  import java.util.HashMap
@@ -124,6 +125,16 @@ class RCTMGLModule(private val mReactContext: ReactApplicationContext) : ReactCo
124
125
  // NO-OP
125
126
  }
126
127
 
128
+ @ReactMethod
129
+ fun addCustomHeader(headerName: String, headerValue: String) {
130
+ CustomHttpHeaders.addCustomHeader(headerName, headerValue)
131
+ }
132
+
133
+ @ReactMethod
134
+ fun removeCustomHeader(headerName: String) {
135
+ CustomHttpHeaders.removeCustomHeader(headerName)
136
+ }
137
+
127
138
  companion object {
128
139
  const val REACT_CLASS = "RCTMGLModule"
129
140
  private val customHeaderInterceptorAdded = false
@@ -132,4 +143,4 @@ class RCTMGLModule(private val mReactContext: ReactApplicationContext) : ReactCo
132
143
  return getDefault((reactContext)!!, null).resourceOptions.accessToken
133
144
  }
134
145
  }
135
- }
146
+ }
@@ -0,0 +1,35 @@
1
+ package com.mapbox.rctmgl.utils
2
+
3
+ import com.mapbox.geojson.Point
4
+ import com.mapbox.maps.CoordinateBounds
5
+ import com.mapbox.rctmgl.utils.LatLngBounds
6
+
7
+ class LatLngBounds internal constructor(
8
+ var latNorth: Double,
9
+ var lonEast: Double,
10
+ var latSouth: Double,
11
+ var lonWest: Double
12
+ ) {
13
+ val southWest: LatLng
14
+ get() = LatLng(latSouth, lonWest)
15
+ val northEast: LatLng
16
+ get() = LatLng(latNorth, lonEast)
17
+
18
+ fun toLatLngs(): Array<LatLng> {
19
+ return arrayOf(northEast, southWest)
20
+ }
21
+
22
+ fun toBounds(): CoordinateBounds {
23
+ return CoordinateBounds(
24
+ Point.fromLngLat(lonWest, latSouth),
25
+ Point.fromLngLat(lonEast, latNorth),
26
+ false
27
+ )
28
+ }
29
+
30
+ companion object {
31
+ fun from(bbox: Double, bbox1: Double, bbox2: Double, bbox3: Double): LatLngBounds {
32
+ return LatLngBounds(bbox, bbox1, bbox2, bbox3)
33
+ }
34
+ }
35
+ }
@@ -0,0 +1,23 @@
1
+ package com.mapbox.rctmgl.utils.extensions
2
+
3
+ import com.facebook.react.bridge.Arguments
4
+ import com.facebook.react.bridge.ReadableArray
5
+ import com.mapbox.maps.CoordinateBounds
6
+ import com.mapbox.rctmgl.utils.GeoJSONUtils
7
+ import com.mapbox.rctmgl.utils.LatLng
8
+
9
+ fun CoordinateBounds.toReadableArray() : ReadableArray {
10
+ val array = Arguments.createArray()
11
+ val ne = northeast
12
+ val sw = southwest
13
+ val latLngs = arrayOf(
14
+ LatLng(ne.latitude(), ne.longitude()),
15
+ LatLng(ne.latitude(), sw.longitude()),
16
+ LatLng(sw.latitude(), sw.longitude()),
17
+ LatLng(sw.latitude(), ne.longitude())
18
+ )
19
+ for (latLng in latLngs) {
20
+ array.pushArray(GeoJSONUtils.fromLatLng(latLng))
21
+ }
22
+ return array
23
+ }
package/docs/docs.json CHANGED
@@ -3939,10 +3939,10 @@
3939
3939
  "name": "Promise",
3940
3940
  "elements": [
3941
3941
  {
3942
- "name": "string"
3942
+ "name": "number"
3943
3943
  }
3944
3944
  ],
3945
- "raw": "Promise<string>"
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
- // Properties set on RCTMGLCamera in React Native.
111
+ // MARK: React properties
112
+
112
113
  @objc var animationDuration: NSNumber?
113
114
  @objc var animationMode: NSString?
114
115
  @objc var defaultStop: [String: Any]?
@@ -145,8 +146,19 @@ class RCTMGLCamera : RCTMGLMapComponentBase, LocationConsumer {
145
146
  _updateCamera()
146
147
  }
147
148
  }
149
+
150
+ @objc var maxBounds: String? {
151
+ didSet {
152
+ if let maxBounds = maxBounds {
153
+ logged("RCTMGLCamera.maxBounds") {
154
+ let maxBoundsFeature = try JSONDecoder().decode(FeatureCollection.self, from: maxBounds.data(using: .utf8)!)
155
+ try _updateMaxBounds(maxBoundsFeature)
156
+ }
157
+ }
158
+ }
159
+ }
148
160
 
149
- // Update methods.
161
+ // MARK: Update methods
150
162
 
151
163
  func _updateCameraFromJavascript() {
152
164
  guard !followUserLocation else {
@@ -185,6 +197,29 @@ class RCTMGLCamera : RCTMGLMapComponentBase, LocationConsumer {
185
197
  map.viewport.idle()
186
198
  map.location.removeLocationConsumer(consumer: self)
187
199
  }
200
+
201
+ func _toCoordinateBounds(_ bounds: FeatureCollection) throws -> CoordinateBounds {
202
+ guard bounds.features.count == 2 else {
203
+ throw RCTMGLError.paramError("Expected two Points in FeatureColletion")
204
+ }
205
+ let swFeature = bounds.features[0]
206
+ let neFeature = bounds.features[1]
207
+
208
+ guard case let .point(sw) = swFeature.geometry,
209
+ case let .point(ne) = neFeature.geometry else {
210
+ throw RCTMGLError.paramError("Expected two Points in FeatureColletion")
211
+ }
212
+
213
+ return CoordinateBounds(southwest: sw.coordinates, northeast: ne.coordinates)
214
+ }
215
+
216
+ func _updateMaxBounds(_ bounds: FeatureCollection) throws {
217
+ withMapView { map in
218
+ logged("RCTMGLCamera._updateMaxBounds") {
219
+ try map.mapboxMap.setCameraBounds(with: CameraBoundsOptions(bounds: try self._toCoordinateBounds(bounds)))
220
+ }
221
+ }
222
+ }
188
223
 
189
224
  func _updateCameraFromTrackingMode() {
190
225
  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)
@@ -4,6 +4,8 @@ import MapKit
4
4
 
5
5
  @objc(RCTMGLMapView)
6
6
  open class RCTMGLMapView : MapView {
7
+ var tapDelegate: IgnoreRCTMGLMakerViewGestureDelegate? = nil
8
+
7
9
  var compassEnabled: Bool = false
8
10
  var compassFadeWhenNorth: Bool = false
9
11
  var reactOnPress : RCTBubblingEventBlock?
@@ -420,12 +422,70 @@ extension RCTMGLMapView {
420
422
 
421
423
  // MARK: - gestures
422
424
 
425
+ class IgnoreRCTMGLMakerViewGestureDelegate : NSObject, UIGestureRecognizerDelegate {
426
+ var originalDelegate: UIGestureRecognizerDelegate?
427
+
428
+ init(originalDelegate: UIGestureRecognizerDelegate?) {
429
+ self.originalDelegate = originalDelegate
430
+ }
431
+
432
+ func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
433
+ return originalDelegate?.gestureRecognizerShouldBegin?(gestureRecognizer) ?? true
434
+ }
435
+
436
+ func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
437
+ return originalDelegate?.gestureRecognizer?(gestureRecognizer,shouldRecognizeSimultaneouslyWith: otherGestureRecognizer) ?? false
438
+ }
439
+
440
+ func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRequireFailureOf otherGestureRecognizer: UIGestureRecognizer) -> Bool {
441
+ return originalDelegate?.gestureRecognizer?(gestureRecognizer,shouldRequireFailureOf: otherGestureRecognizer) ?? false
442
+ }
443
+
444
+ func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldBeRequiredToFailBy otherGestureRecognizer: UIGestureRecognizer) -> Bool {
445
+ return originalDelegate?.gestureRecognizer?(gestureRecognizer,shouldBeRequiredToFailBy: otherGestureRecognizer) ?? false
446
+ }
447
+
448
+ private func isMarkerViewSubview(_ view: UIView) -> Bool {
449
+ var current : UIView? = view
450
+ while let act = current {
451
+ if (act is RCTMGLMarkerView) {
452
+ return true
453
+ }
454
+ current = act.superview
455
+ }
456
+ return false
457
+ }
458
+
459
+ func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool {
460
+ if let view = touch.view, isMarkerViewSubview(view) {
461
+ return false
462
+ }
463
+ return originalDelegate?.gestureRecognizer?(gestureRecognizer,shouldReceive: touch) ?? true
464
+ }
465
+
466
+ func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive press: UIPress) -> Bool {
467
+ return originalDelegate?.gestureRecognizer?(gestureRecognizer,shouldReceive: press) ?? true
468
+ }
469
+
470
+
471
+ @available(iOS 13.4, *)
472
+ func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive event: UIEvent) -> Bool {
473
+ return originalDelegate?.gestureRecognizer?(gestureRecognizer,shouldReceive: event) ?? true
474
+ }
475
+ }
476
+
423
477
  extension RCTMGLMapView {
478
+
424
479
  @objc func setReactOnPress(_ value: @escaping RCTBubblingEventBlock) {
425
480
  self.reactOnPress = value
426
-
427
- self.mapView.gestures.singleTapGestureRecognizer.removeTarget( pointAnnotationManager.manager, action: nil)
428
- self.mapView.gestures.singleTapGestureRecognizer.addTarget(self, action: #selector(doHandleTap(_:)))
481
+
482
+ let singleTapGestureRecognizer = self.mapView.gestures.singleTapGestureRecognizer
483
+
484
+ singleTapGestureRecognizer.removeTarget(pointAnnotationManager.manager, action: nil)
485
+ singleTapGestureRecognizer.addTarget(self, action: #selector(doHandleTap(_:)))
486
+
487
+ self.tapDelegate = IgnoreRCTMGLMakerViewGestureDelegate(originalDelegate: singleTapGestureRecognizer.delegate)
488
+ singleTapGestureRecognizer.delegate = tapDelegate
429
489
  }
430
490
 
431
491
  @objc func setReactOnLongPress(_ value: @escaping RCTBubblingEventBlock) {
@@ -673,6 +733,11 @@ class PointAnnotationManager : AnnotationInteractionDelegate {
673
733
  private var draggedAnnotation: PointAnnotation?
674
734
 
675
735
  func annotationManager(_ manager: AnnotationManager, didDetectTappedAnnotations annotations: [Annotation]) {
736
+ // We handle taps ourselfs
737
+ // onTap(annotations: annotations)
738
+ }
739
+
740
+ func onTap(annotations: [Annotation]) {
676
741
  guard annotations.count > 0 else {
677
742
  fatalError("didDetectTappedAnnotations: No annotations found")
678
743
  }
@@ -724,7 +789,7 @@ class PointAnnotationManager : AnnotationInteractionDelegate {
724
789
  }
725
790
  let options = RenderedQueryOptions(layerIds: [layerId], filter: nil)
726
791
  mapFeatureQueryable.queryRenderedFeatures(
727
- at: tap.location(in: tap.view),
792
+ with: tap.location(in: tap.view),
728
793
  options: options) { [weak self] (result) in
729
794
 
730
795
  guard let self = self else { return }
@@ -746,10 +811,7 @@ class PointAnnotationManager : AnnotationInteractionDelegate {
746
811
 
747
812
  // If `tappedAnnotations` is not empty, call delegate
748
813
  if !tappedAnnotations.isEmpty {
749
- self.annotationManager(
750
- self.manager,
751
- didDetectTappedAnnotations: tappedAnnotations)
752
-
814
+ self.onTap(annotations: tappedAnnotations)
753
815
  } else {
754
816
  noAnnotationFound(tap)
755
817
  }
@@ -757,7 +819,6 @@ class PointAnnotationManager : AnnotationInteractionDelegate {
757
819
  case .failure(let error):
758
820
  noAnnotationFound(tap)
759
821
  Logger.log(level:.warn, message:"Failed to query map for annotations due to error: \(error)")
760
-
761
822
  }
762
823
  }
763
824
  }
@@ -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
- _ clusterId: NSNumber,
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
- let options = SourceQueryOptions(sourceLayerIds: nil, filter: Exp(.eq) {
204
- Exp(.get) { "cluster_id" }
205
- clusterId.uintValue
206
- })
207
- mapView.mapboxMap.querySourceFeatures(for: id, options: options) { result in
208
- switch result {
209
- case .success(let features):
210
- let cluster = features[0]
211
- mapView.mapboxMap.queryFeatureExtension(for: self.id, feature: cluster.feature, extension: "supercluster", extensionField: "expansion-zoom") { result in
212
- switch result {
213
- case .success(let features):
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
- clusterId:(nonnull NSNumber*)clusterId
29
- resolver:(RCTPromiseResolveBlock)resolve
30
- rejecter:(RCTPromiseRejectBlock)reject)
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
- clusterId: NSNumber,
41
+ featureJSON: String,
42
42
  resolver: @escaping RCTPromiseResolveBlock,
43
43
  rejecter: @escaping RCTPromiseRejectBlock) -> Void
44
44
  {
45
- self.withShapeSource(reactTag, name:"getClusterExpansionZoom", rejecter: rejecter) { shapeSource in
46
- shapeSource.getClusterExpansionZoom(clusterId) { result in
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([
@@ -119,8 +119,22 @@ 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
+ console.log('e => ');
124
+ e.stopPropagation();
125
+ }}
122
126
  >
123
- <View style={{ flex: 0, alignSelf: 'flex-start' }}>
127
+ <View
128
+ style={{ flex: 0, alignSelf: 'flex-start' }}
129
+ onStartShouldSetResponder={(_event) => {
130
+ console.log('+> onStart');
131
+ return true;
132
+ }}
133
+ onTouchEnd={(e) => {
134
+ console.log('e => ');
135
+ e.stopPropagation();
136
+ }}
137
+ >
124
138
  {this.props.children}
125
139
  </View>
126
140
  </RCTMGLMarkerView>
@@ -210,12 +210,12 @@ export class ShapeSource extends NativeBridgeComponent(
210
210
  */
211
211
  async getClusterExpansionZoom(
212
212
  feature: string | GeoJSON.Feature,
213
- ): Promise<string> {
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: string } = await this._runNativeCommand(
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: string } = await this._runNativeCommand(
226
+ const res: { data: number } = await this._runNativeCommand(
227
227
  'getClusterExpansionZoom',
228
228
  this._nativeRef,
229
229
  [JSON.stringify(feature)],
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rnmapbox/maps",
3
3
  "description": "A Mapbox react native module for creating custom maps",
4
- "version": "10.0.0-beta.45",
4
+ "version": "10.0.0-beta.47",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -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
- }