@rnmapbox/maps 10.0.0-beta.44 → 10.0.0-beta.46

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 (37) hide show
  1. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/RCTMGLPackage.java +0 -2
  2. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/annotation/RCTMGLMarkerView.kt +162 -51
  3. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/annotation/RCTMGLMarkerViewManager.kt +10 -0
  4. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/annotation/RCTMGLPointAnnotation.kt +6 -6
  5. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/camera/CameraStop.kt +5 -1
  6. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/images/RCTMGLImages.kt +22 -2
  7. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/mapview/RCTMGLMapView.kt +17 -19
  8. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/RCTMGLStyle.kt +1 -1
  9. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/modules/CustomHttpHeaders.kt +38 -0
  10. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/modules/RCTMGLModule.kt +12 -1
  11. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/utils/DownloadMapImageTask.kt +2 -1
  12. package/docs/MapboxGL.md +1 -1
  13. package/docs/MarkerView.md +17 -10
  14. package/docs/PointAnnotation.md +1 -1
  15. package/docs/SymbolLayer.md +1 -1
  16. package/docs/docs.json +116 -102
  17. package/index.d.ts +1 -0
  18. package/ios/RCTMGL-v10/RCTLog.swift +5 -5
  19. package/ios/RCTMGL-v10/RCTMGLMapView.swift +70 -9
  20. package/ios/RCTMGL-v10/RCTMGLMapViewManager.swift +2 -2
  21. package/ios/RCTMGL-v10/RCTMGLMarkerView.swift +186 -105
  22. package/ios/RCTMGL-v10/RCTMGLMarkerViewManager.m +2 -1
  23. package/ios/RCTMGL-v10/RCTMGLShapeSourceManager.swift +1 -1
  24. package/ios/RCTMGL-v10/RCTMGLUtils.swift +1 -1
  25. package/ios/RCTMGL-v10/RCTMGLVectorLayer.swift +1 -1
  26. package/javascript/components/AbstractLayer.tsx +6 -3
  27. package/javascript/components/MarkerView.tsx +81 -77
  28. package/javascript/components/PointAnnotation.tsx +1 -1
  29. package/javascript/components/SymbolLayer.tsx +2 -2
  30. package/javascript/utils/index.d.ts +3 -3
  31. package/package.json +1 -1
  32. package/scripts/autogenHelpers/DocJSONBuilder.js +17 -1
  33. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/annotation/RCTMGLMarkerViewWrapper.kt +0 -8
  34. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/annotation/RCTMGLMarkerViewWrapperManager.kt +0 -21
  35. package/ios/RCTMGL-v10/RCTMGLMarkerViewWrapper.swift +0 -24
  36. package/ios/RCTMGL-v10/RCTMGLMarkerViewWrapperManager.m +0 -8
  37. package/ios/RCTMGL-v10/RCTMGLMarkerViewWrapperManager.swift +0 -14
package/docs/docs.json CHANGED
@@ -1,4 +1,98 @@
1
1
  {
2
+ "Annotation": {
3
+ "description": "",
4
+ "displayName": "Annotation",
5
+ "methods": [
6
+ {
7
+ "name": "onPress",
8
+ "docblock": null,
9
+ "modifiers": [],
10
+ "params": [],
11
+ "returns": null
12
+ },
13
+ {
14
+ "name": "symbolStyle",
15
+ "docblock": null,
16
+ "modifiers": [
17
+ "get"
18
+ ],
19
+ "params": [],
20
+ "returns": null
21
+ }
22
+ ],
23
+ "props": [
24
+ {
25
+ "name": "id",
26
+ "required": true,
27
+ "type": "string",
28
+ "default": "none",
29
+ "description": "FIX ME NO DESCRIPTION"
30
+ },
31
+ {
32
+ "name": "animated",
33
+ "required": false,
34
+ "type": "bool",
35
+ "default": "false",
36
+ "description": "FIX ME NO DESCRIPTION"
37
+ },
38
+ {
39
+ "name": "animationDuration",
40
+ "required": false,
41
+ "type": "number",
42
+ "default": "1000",
43
+ "description": "FIX ME NO DESCRIPTION"
44
+ },
45
+ {
46
+ "name": "animationEasingFunction",
47
+ "required": false,
48
+ "type": "func",
49
+ "default": "Easing.linear",
50
+ "description": "FIX ME NO DESCRIPTION"
51
+ },
52
+ {
53
+ "name": "coordinates",
54
+ "required": false,
55
+ "type": {
56
+ "name": "array",
57
+ "value": {
58
+ "type": "number"
59
+ }
60
+ },
61
+ "default": "none",
62
+ "description": "FIX ME NO DESCRIPTION"
63
+ },
64
+ {
65
+ "name": "onPress",
66
+ "required": false,
67
+ "type": "func",
68
+ "default": "none",
69
+ "description": "FIX ME NO DESCRIPTION"
70
+ },
71
+ {
72
+ "name": "children",
73
+ "required": false,
74
+ "type": "any",
75
+ "default": "none",
76
+ "description": "FIX ME NO DESCRIPTION"
77
+ },
78
+ {
79
+ "name": "style",
80
+ "required": false,
81
+ "type": "any",
82
+ "default": "none",
83
+ "description": "FIX ME NO DESCRIPTION"
84
+ },
85
+ {
86
+ "name": "icon",
87
+ "required": false,
88
+ "type": "union",
89
+ "default": "none",
90
+ "description": "FIX ME NO DESCRIPTION"
91
+ }
92
+ ],
93
+ "fileNameWithExt": "Annotation.js",
94
+ "name": "Annotation"
95
+ },
2
96
  "Atmosphere": {
3
97
  "description": "",
4
98
  "displayName": "Atmosphere",
@@ -3166,7 +3260,7 @@
3166
3260
  "name": "MapView"
3167
3261
  },
3168
3262
  "MarkerView": {
3169
- "description": "MarkerView allows you to place a interactive react native marker to the map.\n\nIf you have static view consider using PointAnnotation or SymbolLayer they'll offer much better performance\n.\nThis is based on [MakerView plugin](https://docs.mapbox.com/android/plugins/overview/markerview/) on Android\nand PointAnnotation on iOS.",
3263
+ "description": "MarkerView represents an interactive React Native marker on the map.\n\nIf you have static views, consider using PointAnnotation or SymbolLayer to display\nan image, as they'll offer much better performance. Mapbox suggests using this\ncomponent for a maximum of around 100 views displayed at one time.\n\nThis is implemented with view annotations on [Android](https://docs.mapbox.com/android/maps/guides/annotations/view-annotations/)\nand [iOS](https://docs.mapbox.com/ios/maps/guides/annotations/view-annotations).\n\nThis component has no dedicated `onPress` method. Instead, you should handle gestures\nwith the React views passed in as `children`.",
3170
3264
  "displayName": "MarkerView",
3171
3265
  "methods": [],
3172
3266
  "props": [
@@ -3175,7 +3269,7 @@
3175
3269
  "required": true,
3176
3270
  "type": "tuple",
3177
3271
  "default": "none",
3178
- "description": "The center point (specified as a map coordinate) of the marker.\nSee also #anchor."
3272
+ "description": "The center point (specified as a map coordinate) of the marker."
3179
3273
  },
3180
3274
  {
3181
3275
  "name": "anchor",
@@ -3188,26 +3282,40 @@
3188
3282
  "required": true,
3189
3283
  "type": "number",
3190
3284
  "default": "none",
3191
- "description": "`x` of anchor"
3285
+ "description": "FIX ME NO DESCRIPTION"
3192
3286
  },
3193
3287
  {
3194
3288
  "name": "y",
3195
3289
  "required": true,
3196
3290
  "type": "number",
3197
3291
  "default": "none",
3198
- "description": "`y` of anchor"
3292
+ "description": "FIX ME NO DESCRIPTION"
3199
3293
  }
3200
3294
  ]
3201
3295
  },
3202
3296
  "default": "{ x: 0.5, y: 0.5 }",
3203
- "description": "Specifies the anchor being set on a particular point of the annotation.\nThe anchor point is specified in the continuous space [0.0, 1.0] x [0.0, 1.0],\nwhere (0, 0) is the top-left corner of the image, and (1, 1) is the bottom-right corner.\nNote this is only for custom annotations not the default pin view.\nDefaults to the center of the view."
3297
+ "description": "Any coordinate between (0, 0) and (1, 1), where (0, 0) is the top-left corner of\nthe view, and (1, 1) is the bottom-right corner. Defaults to the center at (0.5, 0.5)."
3298
+ },
3299
+ {
3300
+ "name": "allowOverlap",
3301
+ "required": false,
3302
+ "type": "boolean",
3303
+ "default": "false",
3304
+ "description": "@v10\n\nWhether or not nearby markers on the map should all be displayed. If false, adjacent\nmarkers will 'collapse' and only one will be shown. Defaults to false."
3305
+ },
3306
+ {
3307
+ "name": "isSelected",
3308
+ "required": false,
3309
+ "type": "boolean",
3310
+ "default": "false",
3311
+ "description": "FIX ME NO DESCRIPTION"
3204
3312
  },
3205
3313
  {
3206
3314
  "name": "children",
3207
3315
  "required": true,
3208
3316
  "type": "ReactReactElement",
3209
3317
  "default": "none",
3210
- "description": "Expects one child - can be container with multiple elements"
3318
+ "description": "One or more valid React Native views."
3211
3319
  }
3212
3320
  ],
3213
3321
  "fileNameWithExt": "MarkerView.tsx",
@@ -3237,7 +3345,7 @@
3237
3345
  "name": "NativeUserLocation"
3238
3346
  },
3239
3347
  "PointAnnotation": {
3240
- "description": "PointAnnotation represents a one-dimensional shape located at a single geographical coordinate.\n\nConsider using ShapeSource and SymbolLayer instead, if you have many points and you have static images,\nthey'll offer much better performance.\n\nIf you need interactive views please use MarkerView,\nas with PointAnnotation on Android child views are rendered onto a bitmap for better performance.",
3348
+ "description": "PointAnnotation represents a one-dimensional shape located at a single geographical coordinate.\n\nConsider using ShapeSource and SymbolLayer instead, if you have many points and you have static images,\nthey'll offer much better performance.\n\nIf you need interactive views please use MarkerView,\nas with PointAnnotation child views are rendered onto a bitmap",
3241
3349
  "displayName": "PointAnnotation",
3242
3350
  "methods": [
3243
3351
  {
@@ -4381,7 +4489,7 @@
4381
4489
  {
4382
4490
  "name": "filter",
4383
4491
  "required": false,
4384
- "type": "Array",
4492
+ "type": "Expression",
4385
4493
  "default": "none",
4386
4494
  "description": "Filter only the features in the source layer that satisfy a condition that you define"
4387
4495
  },
@@ -6117,100 +6225,6 @@
6117
6225
  "fileNameWithExt": "VectorSource.js",
6118
6226
  "name": "VectorSource"
6119
6227
  },
6120
- "Annotation": {
6121
- "description": "",
6122
- "displayName": "Annotation",
6123
- "methods": [
6124
- {
6125
- "name": "onPress",
6126
- "docblock": null,
6127
- "modifiers": [],
6128
- "params": [],
6129
- "returns": null
6130
- },
6131
- {
6132
- "name": "symbolStyle",
6133
- "docblock": null,
6134
- "modifiers": [
6135
- "get"
6136
- ],
6137
- "params": [],
6138
- "returns": null
6139
- }
6140
- ],
6141
- "props": [
6142
- {
6143
- "name": "id",
6144
- "required": true,
6145
- "type": "string",
6146
- "default": "none",
6147
- "description": "FIX ME NO DESCRIPTION"
6148
- },
6149
- {
6150
- "name": "animated",
6151
- "required": false,
6152
- "type": "bool",
6153
- "default": "false",
6154
- "description": "FIX ME NO DESCRIPTION"
6155
- },
6156
- {
6157
- "name": "animationDuration",
6158
- "required": false,
6159
- "type": "number",
6160
- "default": "1000",
6161
- "description": "FIX ME NO DESCRIPTION"
6162
- },
6163
- {
6164
- "name": "animationEasingFunction",
6165
- "required": false,
6166
- "type": "func",
6167
- "default": "Easing.linear",
6168
- "description": "FIX ME NO DESCRIPTION"
6169
- },
6170
- {
6171
- "name": "coordinates",
6172
- "required": false,
6173
- "type": {
6174
- "name": "array",
6175
- "value": {
6176
- "type": "number"
6177
- }
6178
- },
6179
- "default": "none",
6180
- "description": "FIX ME NO DESCRIPTION"
6181
- },
6182
- {
6183
- "name": "onPress",
6184
- "required": false,
6185
- "type": "func",
6186
- "default": "none",
6187
- "description": "FIX ME NO DESCRIPTION"
6188
- },
6189
- {
6190
- "name": "children",
6191
- "required": false,
6192
- "type": "any",
6193
- "default": "none",
6194
- "description": "FIX ME NO DESCRIPTION"
6195
- },
6196
- {
6197
- "name": "style",
6198
- "required": false,
6199
- "type": "any",
6200
- "default": "none",
6201
- "description": "FIX ME NO DESCRIPTION"
6202
- },
6203
- {
6204
- "name": "icon",
6205
- "required": false,
6206
- "type": "union",
6207
- "default": "none",
6208
- "description": "FIX ME NO DESCRIPTION"
6209
- }
6210
- ],
6211
- "fileNameWithExt": "Annotation.js",
6212
- "name": "Annotation"
6213
- },
6214
6228
  "offlineManager": {
6215
6229
  "name": "offlineManager",
6216
6230
  "fileNameWithExt": "offlineManager.js",
package/index.d.ts CHANGED
@@ -153,6 +153,7 @@ declare namespace MapboxGL {
153
153
  const PointAnnotation = _PointAnnotation;
154
154
  const SymbolLayer = _SymbolLayer;
155
155
  const ShapeSource = _ShapeSource;
156
+ type ShapeSource = _ShapeSource;
156
157
 
157
158
  type MapboxGLEvent = _MapboxGLEvent;
158
159
  type UserTrackingMode = _UserTrackingMode;
@@ -1,19 +1,19 @@
1
- func RCTLogError(_ message: String, _ file: String=#file, _ line: UInt=#line) {
1
+ func RCTMGLLogError(_ message: String, _ file: String=#file, _ line: UInt=#line) {
2
2
  RCTMGLSwiftLog.error(message, file: file, line: line)
3
3
  }
4
4
 
5
- func RCTLogWarn(_ message: String, _ file: String=#file, _ line: UInt=#line) {
5
+ func RCTMGLLogWarn(_ message: String, _ file: String=#file, _ line: UInt=#line) {
6
6
  RCTMGLSwiftLog.warn(message, file: file, line: line)
7
7
  }
8
8
 
9
- func RCTLogInfo(_ message: String, _ file: String=#file, _ line: UInt=#line) {
9
+ func RCTMGLLogInfo(_ message: String, _ file: String=#file, _ line: UInt=#line) {
10
10
  RCTMGLSwiftLog.info(message, file: file, line: line)
11
11
  }
12
12
 
13
- func RCTLog(_ message: String, _ file: String=#file, _ line: UInt=#line) {
13
+ func RCTMGLLog(_ message: String, _ file: String=#file, _ line: UInt=#line) {
14
14
  RCTMGLSwiftLog.log(message, file: file, line: line)
15
15
  }
16
16
 
17
- func RCTLogTrace(_ message: String, _ file: String=#file, _ line: UInt=#line) {
17
+ func RCTMGLLogTrace(_ message: String, _ file: String=#file, _ line: UInt=#line) {
18
18
  RCTMGLSwiftLog.trace(message, file: file, line: line)
19
19
  }
@@ -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
  }
@@ -30,7 +30,7 @@ extension RCTMGLMapViewManager {
30
30
  let view = viewRegistry![reactTag]
31
31
 
32
32
  guard let view = view! as? RCTMGLMapView else {
33
- RCTLogError("Invalid react tag, could not find RCTMGLMapView");
33
+ RCTMGLLogError("Invalid react tag, could not find RCTMGLMapView");
34
34
  rejecter(name, "Unknown find reactTag: \(reactTag)", nil)
35
35
  return;
36
36
  }
@@ -47,7 +47,7 @@ extension RCTMGLMapViewManager {
47
47
  {
48
48
  withMapView(reactTag, name: name, rejecter: rejecter) { view in
49
49
  guard let mapboxMap = view.mapboxMap else {
50
- RCTLogError("MapboxMap is not yet available");
50
+ RCTMGLLogError("MapboxMap is not yet available");
51
51
  rejecter(name, "Map not loaded yet", nil)
52
52
  return;
53
53
  }