@rnmapbox/maps 10.0.0-beta.76 → 10.0.0-beta.77

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 (202) hide show
  1. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/RCTMGLStyle.kt +7 -1
  2. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/RCTMGLStyleFactory.java +5 -5
  3. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTLayer.kt +37 -10
  4. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLBackgroundLayer.kt +21 -0
  5. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLBackgroundLayerManager.kt +65 -0
  6. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLCircleLayer.kt +40 -0
  7. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLCircleLayerManager.kt +76 -0
  8. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLFillExtrusionLayer.kt +43 -0
  9. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLFillExtrusionLayerManager.kt +76 -0
  10. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLFillLayer.kt +40 -0
  11. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLFillLayerManager.kt +76 -0
  12. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLHeatmapLayer.kt +40 -0
  13. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLHeatmapLayerManager.kt +76 -0
  14. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLLineLayer.kt +40 -0
  15. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLLineLayerManager.kt +76 -0
  16. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLRasterLayer.kt +18 -0
  17. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLRasterLayerManager.kt +65 -0
  18. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLSkyLayerManager.kt +76 -0
  19. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLSymbolLayer.kt +40 -0
  20. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLSymbolLayerManager.kt +76 -0
  21. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLImageSource.kt +69 -0
  22. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLImageSourceManager.kt +54 -0
  23. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLRasterDemSource.kt +82 -0
  24. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLRasterDemSourceManager.kt +30 -0
  25. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLRasterSource.kt +37 -0
  26. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLRasterSourceManager.kt +32 -0
  27. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLShapeSource.kt +5 -0
  28. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLShapeSourceManager.kt +10 -4
  29. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLTileSource.kt +44 -0
  30. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLTileSourceManager.kt +69 -0
  31. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLVectorSource.kt +78 -0
  32. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLVectorSourceManager.kt +69 -0
  33. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTSource.kt +101 -85
  34. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/events/PointAnnotationDragEvent.java +4 -2
  35. package/ios/RCTMGL-v10/RCTMGLCamera.swift +11 -31
  36. package/ios/RCTMGL-v10/RCTMGLInteractiveElement.swift +13 -1
  37. package/ios/RCTMGL-v10/RCTMGLLayer.swift +35 -6
  38. package/ios/RCTMGL-v10/RCTMGLLocationModule.swift +27 -4
  39. package/ios/RCTMGL-v10/RCTMGLMapView.swift +4 -2
  40. package/ios/RCTMGL-v10/RCTMGLSource.swift +35 -17
  41. package/javascript/Mapbox.ts +4 -1
  42. package/javascript/components/AbstractLayer.tsx +2 -1
  43. package/javascript/components/BackgroundLayer.tsx +6 -1
  44. package/javascript/components/{Callout.js → Callout.tsx} +53 -45
  45. package/javascript/components/CircleLayer.tsx +5 -0
  46. package/javascript/components/FillExtrusionLayer.tsx +6 -1
  47. package/javascript/components/FillLayer.tsx +5 -0
  48. package/javascript/components/HeadingIndicator.tsx +24 -13
  49. package/javascript/components/HeatmapLayer.tsx +6 -1
  50. package/javascript/components/ImageSource.tsx +5 -0
  51. package/javascript/components/LineLayer.tsx +5 -0
  52. package/javascript/components/PointAnnotation.tsx +8 -4
  53. package/javascript/components/RasterDemSource.tsx +5 -0
  54. package/javascript/components/RasterLayer.tsx +6 -1
  55. package/javascript/components/RasterSource.tsx +5 -0
  56. package/javascript/components/ShapeSource.tsx +5 -0
  57. package/javascript/components/SkyLayer.tsx +5 -0
  58. package/javascript/components/SymbolLayer.tsx +6 -1
  59. package/javascript/components/UserLocation.tsx +1 -1
  60. package/javascript/components/VectorSource.tsx +5 -0
  61. package/javascript/types/BaseProps.ts +1 -0
  62. package/javascript/utils/index.ts +0 -8
  63. package/javascript/utils/styleMap.ts +0 -1598
  64. package/lib/commonjs/Mapbox.js +8 -1
  65. package/lib/commonjs/Mapbox.js.map +1 -1
  66. package/lib/commonjs/components/AbstractLayer.js +1 -2
  67. package/lib/commonjs/components/AbstractLayer.js.map +1 -1
  68. package/lib/commonjs/components/BackgroundLayer.js.map +1 -1
  69. package/lib/commonjs/components/Callout.js +7 -33
  70. package/lib/commonjs/components/Callout.js.map +1 -1
  71. package/lib/commonjs/components/CircleLayer.js.map +1 -1
  72. package/lib/commonjs/components/FillExtrusionLayer.js.map +1 -1
  73. package/lib/commonjs/components/FillLayer.js.map +1 -1
  74. package/lib/commonjs/components/HeadingIndicator.js +12 -3
  75. package/lib/commonjs/components/HeadingIndicator.js.map +1 -1
  76. package/lib/commonjs/components/HeatmapLayer.js.map +1 -1
  77. package/lib/commonjs/components/ImageSource.js.map +1 -1
  78. package/lib/commonjs/components/LineLayer.js.map +1 -1
  79. package/lib/commonjs/components/PointAnnotation.js.map +1 -1
  80. package/lib/commonjs/components/RasterDemSource.js.map +1 -1
  81. package/lib/commonjs/components/RasterLayer.js.map +1 -1
  82. package/lib/commonjs/components/RasterSource.js.map +1 -1
  83. package/lib/commonjs/components/ShapeSource.js.map +1 -1
  84. package/lib/commonjs/components/SkyLayer.js.map +1 -1
  85. package/lib/commonjs/components/SymbolLayer.js.map +1 -1
  86. package/lib/commonjs/components/UserLocation.js +2 -1
  87. package/lib/commonjs/components/UserLocation.js.map +1 -1
  88. package/lib/commonjs/components/VectorSource.js.map +1 -1
  89. package/lib/commonjs/utils/index.js +0 -16
  90. package/lib/commonjs/utils/index.js.map +1 -1
  91. package/lib/commonjs/utils/styleMap.js +1 -1217
  92. package/lib/commonjs/utils/styleMap.js.map +1 -1
  93. package/lib/module/Mapbox.js +1 -1
  94. package/lib/module/Mapbox.js.map +1 -1
  95. package/lib/module/components/AbstractLayer.js +1 -1
  96. package/lib/module/components/AbstractLayer.js.map +1 -1
  97. package/lib/module/components/BackgroundLayer.js.map +1 -1
  98. package/lib/module/components/Callout.js +7 -33
  99. package/lib/module/components/Callout.js.map +1 -1
  100. package/lib/module/components/CircleLayer.js.map +1 -1
  101. package/lib/module/components/FillExtrusionLayer.js.map +1 -1
  102. package/lib/module/components/FillLayer.js.map +1 -1
  103. package/lib/module/components/HeadingIndicator.js +12 -3
  104. package/lib/module/components/HeadingIndicator.js.map +1 -1
  105. package/lib/module/components/HeatmapLayer.js.map +1 -1
  106. package/lib/module/components/ImageSource.js.map +1 -1
  107. package/lib/module/components/LineLayer.js.map +1 -1
  108. package/lib/module/components/PointAnnotation.js.map +1 -1
  109. package/lib/module/components/RasterDemSource.js.map +1 -1
  110. package/lib/module/components/RasterLayer.js.map +1 -1
  111. package/lib/module/components/RasterSource.js.map +1 -1
  112. package/lib/module/components/ShapeSource.js.map +1 -1
  113. package/lib/module/components/SkyLayer.js.map +1 -1
  114. package/lib/module/components/SymbolLayer.js.map +1 -1
  115. package/lib/module/components/UserLocation.js +2 -1
  116. package/lib/module/components/UserLocation.js.map +1 -1
  117. package/lib/module/components/VectorSource.js.map +1 -1
  118. package/lib/module/utils/index.js +0 -14
  119. package/lib/module/utils/index.js.map +1 -1
  120. package/lib/module/utils/styleMap.js +0 -1201
  121. package/lib/module/utils/styleMap.js.map +1 -1
  122. package/lib/typescript/Mapbox.d.ts +1 -1
  123. package/lib/typescript/Mapbox.d.ts.map +1 -1
  124. package/lib/typescript/components/AbstractLayer.d.ts +1 -0
  125. package/lib/typescript/components/AbstractLayer.d.ts.map +1 -1
  126. package/lib/typescript/components/BackgroundLayer.d.ts +5 -1
  127. package/lib/typescript/components/BackgroundLayer.d.ts.map +1 -1
  128. package/lib/typescript/components/Callout.d.ts +41 -0
  129. package/lib/typescript/components/Callout.d.ts.map +1 -0
  130. package/lib/typescript/components/CircleLayer.d.ts +4 -0
  131. package/lib/typescript/components/CircleLayer.d.ts.map +1 -1
  132. package/lib/typescript/components/FillExtrusionLayer.d.ts +5 -1
  133. package/lib/typescript/components/FillExtrusionLayer.d.ts.map +1 -1
  134. package/lib/typescript/components/FillLayer.d.ts +4 -0
  135. package/lib/typescript/components/FillLayer.d.ts.map +1 -1
  136. package/lib/typescript/components/HeadingIndicator.d.ts +2 -1
  137. package/lib/typescript/components/HeadingIndicator.d.ts.map +1 -1
  138. package/lib/typescript/components/HeatmapLayer.d.ts +5 -1
  139. package/lib/typescript/components/HeatmapLayer.d.ts.map +1 -1
  140. package/lib/typescript/components/ImageSource.d.ts +4 -0
  141. package/lib/typescript/components/ImageSource.d.ts.map +1 -1
  142. package/lib/typescript/components/LineLayer.d.ts +4 -0
  143. package/lib/typescript/components/LineLayer.d.ts.map +1 -1
  144. package/lib/typescript/components/PointAnnotation.d.ts +5 -9
  145. package/lib/typescript/components/PointAnnotation.d.ts.map +1 -1
  146. package/lib/typescript/components/RasterDemSource.d.ts +4 -0
  147. package/lib/typescript/components/RasterDemSource.d.ts.map +1 -1
  148. package/lib/typescript/components/RasterLayer.d.ts +5 -1
  149. package/lib/typescript/components/RasterLayer.d.ts.map +1 -1
  150. package/lib/typescript/components/RasterSource.d.ts +4 -0
  151. package/lib/typescript/components/RasterSource.d.ts.map +1 -1
  152. package/lib/typescript/components/ShapeSource.d.ts +4 -0
  153. package/lib/typescript/components/ShapeSource.d.ts.map +1 -1
  154. package/lib/typescript/components/SkyLayer.d.ts +4 -0
  155. package/lib/typescript/components/SkyLayer.d.ts.map +1 -1
  156. package/lib/typescript/components/SymbolLayer.d.ts +5 -1
  157. package/lib/typescript/components/SymbolLayer.d.ts.map +1 -1
  158. package/lib/typescript/components/VectorSource.d.ts +4 -0
  159. package/lib/typescript/components/VectorSource.d.ts.map +1 -1
  160. package/lib/typescript/types/BaseProps.d.ts +1 -0
  161. package/lib/typescript/types/BaseProps.d.ts.map +1 -1
  162. package/lib/typescript/utils/index.d.ts +0 -14
  163. package/lib/typescript/utils/index.d.ts.map +1 -1
  164. package/lib/typescript/utils/styleMap.d.ts +0 -1406
  165. package/lib/typescript/utils/styleMap.d.ts.map +1 -1
  166. package/package.json +35 -37
  167. package/plugin/build/withMapbox.d.ts +10 -6
  168. package/plugin/build/withMapbox.js +119 -137
  169. package/plugin/install.md +21 -0
  170. package/plugin/src/withMapbox.ts +166 -138
  171. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLBackgroundLayer.java +0 -23
  172. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLBackgroundLayerManager.java +0 -60
  173. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLCircleLayer.java +0 -53
  174. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLCircleLayerManager.java +0 -73
  175. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLFillExtrusionLayer.java +0 -51
  176. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLFillExtrusionLayerManager.java +0 -76
  177. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLFillLayer.java +0 -51
  178. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLFillLayerManager.java +0 -77
  179. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLHeatmapLayer.java +0 -51
  180. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLHeatmapLayerManager.java +0 -73
  181. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLLineLayer.java +0 -51
  182. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLLineLayerManager.java +0 -75
  183. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLRasterLayer.java +0 -24
  184. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLRasterLayerManager.java +0 -60
  185. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLSkyLayerManager.java +0 -73
  186. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLSymbolLayer.java +0 -51
  187. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLSymbolLayerManager.java +0 -71
  188. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLImageSource.java +0 -76
  189. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLImageSourceManager.java +0 -68
  190. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLRasterDemSource.java +0 -122
  191. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLRasterDemSourceManager.java +0 -64
  192. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLRasterSource.java +0 -43
  193. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLRasterSourceManager.java +0 -39
  194. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLTileSource.java +0 -103
  195. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLTileSourceManager.java +0 -80
  196. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLVectorSource.java +0 -100
  197. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLVectorSourceManager.java +0 -80
  198. package/javascript/components/Callout.d.ts +0 -35
  199. package/lib/commonjs/components/Callout.d.js +0 -9
  200. package/lib/commonjs/components/Callout.d.js.map +0 -1
  201. package/lib/module/components/Callout.d.js +0 -2
  202. package/lib/module/components/Callout.d.js.map +0 -1
@@ -43,9 +43,11 @@ public class PointAnnotationDragEvent extends MapClickEvent {
43
43
  @Override
44
44
  public WritableMap getPayload() {
45
45
  WritableMap properties = new WritableNativeMap();
46
- properties.putString("id", mView.getID());
47
46
  properties.putDouble("screenPointX", mScreenPoint.x);
48
47
  properties.putDouble("screenPointY", mScreenPoint.y);
49
- return GeoJSONUtils.toPointFeature(mTouchedLatLng, properties);
48
+ WritableMap feature = GeoJSONUtils.toPointFeature(mTouchedLatLng, properties);
49
+ feature.putString("id", mView.getID());
50
+
51
+ return feature;
50
52
  }
51
53
  }
@@ -2,7 +2,7 @@ import Foundation
2
2
  import MapboxMaps
3
3
  import Turf
4
4
 
5
- protocol RCTMGLMapComponent : AnyObject {
5
+ protocol RCTMGLMapComponent : class {
6
6
  func addToMap(_ map: RCTMGLMapView, style: Style)
7
7
  func removeFromMap(_ map: RCTMGLMapView)
8
8
 
@@ -104,7 +104,7 @@ open class RCTMGLMapComponentBase : UIView, RCTMGLMapComponent {
104
104
  }
105
105
  }
106
106
 
107
- class RCTMGLCamera : RCTMGLMapComponentBase, LocationConsumer {
107
+ class RCTMGLCamera : RCTMGLMapComponentBase {
108
108
  var cameraAnimator: BasicCameraAnimator?
109
109
  let cameraUpdateQueue = CameraUpdateQueue()
110
110
 
@@ -219,7 +219,6 @@ class RCTMGLCamera : RCTMGLMapComponentBase, LocationConsumer {
219
219
 
220
220
  func _disableUsetTracking(_ map: MapView) {
221
221
  map.viewport.idle()
222
- map.location.removeLocationConsumer(consumer: self)
223
222
  }
224
223
 
225
224
  func _toCoordinateBounds(_ bounds: FeatureCollection) throws -> CoordinateBounds {
@@ -274,10 +273,17 @@ class RCTMGLCamera : RCTMGLMapComponentBase, LocationConsumer {
274
273
  }
275
274
 
276
275
  if let locationModule = RCTMGLLocationModule.shared {
277
- map.location.overrideLocationProvider(with: locationModule.locationProvider)
276
+ var isSameProvider = false
277
+ if let currentProvider = map.location.locationProvider as? AnyObject, let newProvider = locationModule.locationProvider as? AnyObject {
278
+ if currentProvider === newProvider {
279
+ isSameProvider = true
280
+ }
281
+ }
282
+ if !isSameProvider {
283
+ map.location.overrideLocationProvider(with: locationModule.locationProvider)
284
+ }
278
285
  }
279
286
  map.location.locationProvider.requestWhenInUseAuthorization()
280
- map.location.addLocationConsumer(newConsumer: self)
281
287
  var trackingModeChanged = false
282
288
  var followOptions = FollowPuckViewportStateOptions()
283
289
  switch userTrackingMode {
@@ -506,32 +512,6 @@ class RCTMGLCamera : RCTMGLMapComponentBase, LocationConsumer {
506
512
  map.viewport.removeStatusObserver(self)
507
513
  super.removeFromMap(map)
508
514
  }
509
-
510
- // MARK: - LocationConsumer
511
-
512
- func locationUpdate(newLocation: Location) {
513
- // viewport manages following user location
514
- if false && followUserLocation {
515
- withMapView { map in
516
- var animationType = CameraMode.none
517
- if let m = self.animationMode as? String, let m = CameraMode(rawValue: m) {
518
- animationType = m
519
- }
520
- let _camera = CameraOptions(center: newLocation.coordinate)
521
- let _duration = self.animationDuration as? Double ?? 0.5
522
- switch (animationType) {
523
- case .flight:
524
- map.camera.fly(to: _camera, duration: _duration)
525
- case .ease:
526
- map.camera.ease(to: _camera, duration: _duration, curve: .easeInOut, completion: nil)
527
- case .linear:
528
- map.camera.ease(to: _camera, duration: _duration, curve: .linear, completion: nil)
529
- default:
530
- map.mapboxMap.setCamera(to: CameraOptions(center: newLocation.coordinate))
531
- }
532
- }
533
- }
534
- }
535
515
  }
536
516
 
537
517
  // MARK: - ViewportStatusObserver
@@ -16,7 +16,19 @@ class RCTMGLInteractiveElement : UIView, RCTMGLMapComponent {
16
16
  "height": NSNumber(value: hitboxDefault)
17
17
  ]
18
18
 
19
- @objc var id: String! = nil
19
+ @objc var id: String! = nil {
20
+ willSet {
21
+ if id != nil && newValue != id {
22
+ Logger.log(level:.warn, message: "Changing id from: \(optional: id) to \(optional: newValue), changing of id is supported")
23
+ if let map = map { removeFromMap(map) }
24
+ }
25
+ }
26
+ didSet {
27
+ if oldValue != nil && oldValue != id {
28
+ if let map = map { addToMap(map, style: map.mapboxMap.style) }
29
+ }
30
+ }
31
+ }
20
32
 
21
33
  @objc var onDragStart: RCTBubblingEventBlock? = nil
22
34
 
@@ -1,6 +1,6 @@
1
1
  @_spi(Experimental) import MapboxMaps
2
2
 
3
- protocol RCTMGLSourceConsumer {
3
+ protocol RCTMGLSourceConsumer : class {
4
4
  func addToMap(_ map: RCTMGLMapView, style: Style)
5
5
  func removeFromMap(_ map: RCTMGLMapView, style: Style)
6
6
  }
@@ -9,6 +9,8 @@ protocol RCTMGLSourceConsumer {
9
9
  class RCTMGLLayer : UIView, RCTMGLMapComponent, RCTMGLSourceConsumer {
10
10
  weak var bridge : RCTBridge? = nil
11
11
 
12
+ var waitingForID: String? = nil
13
+
12
14
  @objc var sourceLayerID : String? = nil {
13
15
  didSet { self.optionsChanged() }
14
16
  }
@@ -31,7 +33,20 @@ class RCTMGLLayer : UIView, RCTMGLMapComponent, RCTMGLSourceConsumer {
31
33
  didSet { optionsChanged() }
32
34
  }
33
35
 
34
- @objc var id: String! = nil
36
+ @objc var id: String! = nil {
37
+ willSet {
38
+ if id != nil && newValue != id {
39
+ Logger.log(level:.warn, message: "Changing id from: \(optional: id) to \(optional: newValue), changing of id is supported")
40
+ if let style = style { self.removeFromMap(style) }
41
+ }
42
+ }
43
+ didSet {
44
+ if oldValue != nil && oldValue != id {
45
+ if let map = map, let style = style { self.addToMap(map, style: style) }
46
+ }
47
+ }
48
+ }
49
+
35
50
  @objc var sourceID: String? = nil {
36
51
  didSet { optionsChanged() }
37
52
  }
@@ -74,6 +89,13 @@ class RCTMGLLayer : UIView, RCTMGLMapComponent, RCTMGLSourceConsumer {
74
89
  }
75
90
 
76
91
  @objc weak var map: RCTMGLMapView? = nil
92
+
93
+ deinit {
94
+ if let waitingForID = waitingForID {
95
+ Logger.log(level:.warn, message: "RCTMGLLayer.removeFromMap - unmetPositionDependency: layer: \(optional: id) was waiting for layer: \(optional: waitingForID) but it hasn't added to map")
96
+ self.waitingForID = nil
97
+ }
98
+ }
77
99
 
78
100
  var styleLayer: Layer? = nil
79
101
 
@@ -86,9 +108,9 @@ class RCTMGLLayer : UIView, RCTMGLMapComponent, RCTMGLSourceConsumer {
86
108
  }
87
109
 
88
110
  func removeAndReaddLayer() {
89
- if let style = style {
111
+ if let map = map, let style = style {
90
112
  self.removeFromMap(style)
91
- self.insert(style, layerPosition: position())
113
+ self.addToMap(map, style:style)
92
114
  }
93
115
  }
94
116
 
@@ -248,7 +270,7 @@ class RCTMGLLayer : UIView, RCTMGLMapComponent, RCTMGLSourceConsumer {
248
270
  }
249
271
 
250
272
  private func optionsChanged() {
251
- if let style = self.style {
273
+ if let style = self.style, self.styleLayer != nil {
252
274
  self.setOptions(&self.styleLayer!)
253
275
  self.loggedApply(style: style)
254
276
  }
@@ -259,10 +281,14 @@ class RCTMGLLayer : UIView, RCTMGLMapComponent, RCTMGLSourceConsumer {
259
281
  }
260
282
 
261
283
  private func removeFromMap(_ style: Style) {
284
+ if let waitingForID = waitingForID {
285
+ Logger.log(level:.warn, message: "RCTMGLLayer.removeFromMap - unmetPositionDependency: layer: \(optional: id) was waiting for layer: \(optional: waitingForID) but it hasn't added to map")
286
+ }
287
+
262
288
  do {
263
289
  try style.removeLayer(withId: self.id)
264
290
  } catch {
265
- Logger.log(level: .error, message: "removing layer failed for layer \(optional: id): \(error.localizedDescription)")
291
+ Logger.log(level: .error, message: "RCTMGLLayer.removeFromMap: removing layer failed for layer \(optional: id): \(error.localizedDescription)")
266
292
  }
267
293
  }
268
294
 
@@ -279,8 +305,11 @@ class RCTMGLLayer : UIView, RCTMGLMapComponent, RCTMGLSourceConsumer {
279
305
  idToWaitFor = nil
280
306
  }
281
307
 
308
+
282
309
  if let idToWaitFor = idToWaitFor {
310
+ self.waitingForID = idToWaitFor
283
311
  map!.waitForLayerWithID(idToWaitFor) { _ in
312
+ self.waitingForID = nil
284
313
  self.attemptInsert(style, layerPosition: layerPosition, onInsert: onInsert)
285
314
  }
286
315
  } else {
@@ -61,6 +61,9 @@ class RCTMGLLocationManager : LocationProviderDelegate {
61
61
  var simulatedHeading: Double = 0.0
62
62
  var simulatedHeadingIncrement: Double = 1.0
63
63
 
64
+ var startUpdatingLocationCalled = false
65
+ var startUpdatingHeadingCalled = false
66
+
64
67
  init() {
65
68
  provider = AppleLocationProvider()
66
69
  provider.setDelegate(self)
@@ -87,9 +90,19 @@ class RCTMGLLocationManager : LocationProviderDelegate {
87
90
  }
88
91
 
89
92
  func stop() {
90
- provider.stopUpdatingHeading()
91
- provider.stopUpdatingLocation()
92
- provider.setDelegate(EmptyLocationProviderDelegate())
93
+ if !startUpdatingHeadingCalled {
94
+ provider.stopUpdatingHeading()
95
+ }
96
+ if !startUpdatingLocationCalled {
97
+ provider.stopUpdatingLocation()
98
+ }
99
+ _clearProviderDelegateIfNotListening()
100
+ }
101
+
102
+ func _clearProviderDelegateIfNotListening() {
103
+ if !startUpdatingHeadingCalled && !startUpdatingLocationCalled {
104
+ provider.setDelegate(EmptyLocationProviderDelegate())
105
+ }
93
106
  }
94
107
 
95
108
  func _convertToMapboxLocation(_ location: CLLocation?, type: LocationUpdateType) -> RCTMGLLocation {
@@ -144,6 +157,8 @@ class RCTMGLLocationManager : LocationProviderDelegate {
144
157
  }
145
158
  }
146
159
 
160
+ // MARK: LocationProvider
161
+
147
162
  extension RCTMGLLocationManager: LocationProvider {
148
163
  var locationProviderOptions: LocationOptions {
149
164
  get {
@@ -194,11 +209,15 @@ extension RCTMGLLocationManager: LocationProvider {
194
209
  }
195
210
 
196
211
  func startUpdatingLocation() {
212
+ startUpdatingLocationCalled = true
197
213
  provider.startUpdatingLocation()
198
214
  }
199
215
 
200
216
  func stopUpdatingLocation() {
201
217
  provider.stopUpdatingLocation()
218
+ startUpdatingLocationCalled = false
219
+
220
+ _clearProviderDelegateIfNotListening()
202
221
  }
203
222
 
204
223
  var headingOrientation: CLDeviceOrientation {
@@ -211,11 +230,15 @@ extension RCTMGLLocationManager: LocationProvider {
211
230
  }
212
231
 
213
232
  func startUpdatingHeading() {
233
+ startUpdatingHeadingCalled = true
214
234
  provider.startUpdatingHeading()
215
235
  }
216
236
 
217
237
  func stopUpdatingHeading() {
238
+ startUpdatingHeadingCalled = false
218
239
  provider.stopUpdatingHeading()
240
+
241
+ _clearProviderDelegateIfNotListening()
219
242
  }
220
243
 
221
244
  func dismissHeadingCalibrationDisplay() {
@@ -276,7 +299,7 @@ extension RCTMGLLocationManager {
276
299
  class RCTMGLLocationModule: RCTEventEmitter, RCTMGLLocationManagerDelegate {
277
300
 
278
301
  static weak var shared : RCTMGLLocationModule? = nil
279
-
302
+
280
303
  var locationManager : RCTMGLLocationManager
281
304
  var hasListener = false
282
305
 
@@ -859,7 +859,8 @@ class PointAnnotationManager : AnnotationInteractionDelegate {
859
859
  if let pt = rctmglPointAnnotation.object {
860
860
  let position = pt.superview?.convert(pt.layer.position, to: nil)
861
861
  let location = pt.map?.mapboxMap.coordinate(for: position!)
862
- var geojson = Feature(geometry: .point(Point(location!)));
862
+ var geojson = Feature(geometry: .point(Point(location!)))
863
+ geojson.identifier = .string(pt.id)
863
864
  geojson.properties = [
864
865
  "screenPointX": .number(Double(position!.x)),
865
866
  "screenPointY": .number(Double(position!.y))
@@ -947,7 +948,8 @@ class PointAnnotationManager : AnnotationInteractionDelegate {
947
948
  if let rctmglPointAnnotation = userInfo[RCTMGLPointAnnotation.key] as? WeakRef<RCTMGLPointAnnotation> {
948
949
  if let pt = rctmglPointAnnotation.object {
949
950
  let position = pt.superview?.convert(pt.layer.position, to: nil)
950
- var geojson = Feature(geometry: .point(Point(targetPoint)));
951
+ var geojson = Feature(geometry: .point(Point(targetPoint)))
952
+ geojson.identifier = .string(pt.id)
951
953
  geojson.properties = [
952
954
  "screenPointX": .number(Double(position!.x)),
953
955
  "screenPointY": .number(Double(position!.y))
@@ -3,6 +3,7 @@
3
3
  @objc
4
4
  class RCTMGLSource : RCTMGLInteractiveElement {
5
5
  var layers: [RCTMGLSourceConsumer] = []
6
+ var components: [RCTMGLMapComponent] = []
6
7
 
7
8
  var source : Source? = nil
8
9
 
@@ -29,16 +30,32 @@ class RCTMGLSource : RCTMGLInteractiveElement {
29
30
  // MARK: - UIView+React
30
31
 
31
32
  @objc override func insertReactSubview(_ subview: UIView!, at atIndex: Int) {
32
- if let layer : RCTMGLSourceConsumer = subview as? RCTMGLSourceConsumer {
33
+ if let layer = subview as? RCTMGLSourceConsumer {
33
34
  if let map = map {
34
35
  layer.addToMap(map, style: map.mapboxMap.style)
35
36
  }
36
37
  layers.append(layer)
38
+ } else if let component = subview as? RCTMGLMapComponent {
39
+ if let map = map {
40
+ component.addToMap(map, style: map.mapboxMap.style)
41
+ }
42
+ components.append(component)
37
43
  }
38
44
  super.insertReactSubview(subview, at: atIndex)
39
45
  }
40
46
 
41
47
  @objc override func removeReactSubview(_ subview: UIView!) {
48
+ if let layer : RCTMGLSourceConsumer = subview as? RCTMGLSourceConsumer {
49
+ if let map = map {
50
+ layer.removeFromMap(map, style: map.mapboxMap.style)
51
+ }
52
+ layers.removeAll { $0 as AnyObject === layer }
53
+ } else if let component = subview as? RCTMGLMapComponent {
54
+ if let map = map {
55
+ component.removeFromMap(map)
56
+ }
57
+ layers.removeAll { $0 as AnyObject === component }
58
+ }
42
59
  super.removeReactSubview(subview)
43
60
  }
44
61
 
@@ -50,28 +67,29 @@ class RCTMGLSource : RCTMGLInteractiveElement {
50
67
 
51
68
  override func addToMap(_ map: RCTMGLMapView, style: Style) {
52
69
  self.map = map
53
-
54
- map.onMapStyleLoaded { mapboxMap in
55
- if style.sourceExists(withId: self.id) {
56
- self.source = try! style.source(withId: self.id)
57
- } else {
58
- let source = self.makeSource()
59
- self.ownsSource = true
60
- self.source = source
61
- logged("SyleSource.addToMap", info: {"id: \(optional: self.id)"}) {
62
- try style.addSource(source, id: self.id)
63
- }
64
- }
65
-
66
- for layer in self.layers {
67
- layer.addToMap(map, style: map.mapboxMap.style)
70
+
71
+ if style.sourceExists(withId: self.id) {
72
+ self.source = try! style.source(withId: self.id)
73
+ } else {
74
+ let source = self.makeSource()
75
+ self.ownsSource = true
76
+ self.source = source
77
+ logged("SyleSource.addToMap", info: {"id: \(optional: self.id)"}) {
78
+ try style.addSource(source, id: self.id)
68
79
  }
69
80
  }
81
+
82
+ for layer in self.layers {
83
+ layer.addToMap(map, style: map.mapboxMap.style)
84
+ }
85
+ for component in self.components {
86
+ component.addToMap(map, style: map.mapboxMap.style)
87
+ }
70
88
  }
71
89
 
72
90
  override func removeFromMap(_ map: RCTMGLMapView) {
73
91
  self.map = nil
74
-
92
+
75
93
  for layer in self.layers {
76
94
  layer.removeFromMap(map, style: map.mapboxMap.style)
77
95
  }
@@ -12,7 +12,10 @@ export { default as Light } from './components/Light';
12
12
  export { default as PointAnnotation } from './components/PointAnnotation';
13
13
  export { default as Annotation } from './components/Annotation';
14
14
  export { default as Callout } from './components/Callout';
15
- export { default as UserLocation } from './components/UserLocation';
15
+ export {
16
+ default as UserLocation,
17
+ UserLocationRenderMode,
18
+ } from './components/UserLocation';
16
19
  export { default as VectorSource } from './components/VectorSource';
17
20
  export { ShapeSource } from './components/ShapeSource';
18
21
  export { default as RasterSource } from './components/RasterSource';
@@ -1,4 +1,3 @@
1
- /* eslint react/prop-types:0 */
2
1
  import React from 'react';
3
2
  import { NativeMethods, processColor } from 'react-native';
4
3
 
@@ -9,6 +8,7 @@ import type { BaseProps } from '../types/BaseProps';
9
8
 
10
9
  type PropsBase = BaseProps & {
11
10
  id: string;
11
+ existing?: boolean;
12
12
  sourceID?: string;
13
13
  minZoomLevel?: number;
14
14
  maxZoomLevel?: number;
@@ -27,6 +27,7 @@ class AbstractLayer<
27
27
  return {
28
28
  ...this.props,
29
29
  id: this.props.id,
30
+ existing: this.props.existing,
30
31
  sourceID: this.props.sourceID,
31
32
  reactStyle: this.getStyle(this.props.style),
32
33
  minZoomLevel: this.props.minZoomLevel,
@@ -13,10 +13,15 @@ const MapboxGL = NativeModules.MGLModule;
13
13
 
14
14
  export type Props = {
15
15
  /**
16
- * A string that uniquely identifies the source in the style to which it is added.
16
+ * A string that uniquely identifies the layer in the style to which it is added.
17
17
  */
18
18
  id: string;
19
19
 
20
+ /**
21
+ * The id refers to en existing layer in the style. Does not create a new layer.
22
+ */
23
+ existing?: boolean;
24
+
20
25
  /**
21
26
  * The source from which to obtain the data to style.
22
27
  * If the source has not yet been added to the current style, the behavior is undefined.
@@ -1,15 +1,15 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
1
+ import React, { ReactNode } from 'react';
3
2
  import {
4
3
  View,
5
4
  Text,
6
5
  Animated,
7
6
  requireNativeComponent,
8
7
  StyleSheet,
8
+ ViewStyle,
9
+ ViewProps,
10
+ StyleProp,
9
11
  } from 'react-native';
10
12
 
11
- import { viewPropTypes } from '../utils';
12
-
13
13
  export const NATIVE_MODULE_NAME = 'RCTMGLCallout';
14
14
 
15
15
  const styles = StyleSheet.create({
@@ -48,60 +48,68 @@ const styles = StyleSheet.create({
48
48
  },
49
49
  });
50
50
 
51
+ type NativeProps = {
52
+ children: ReactNode;
53
+ style: StyleProp<ViewStyle>;
54
+ };
55
+
56
+ type Props = Omit<ViewProps, 'style'> & {
57
+ /**
58
+ * String that gets displayed in the default callout.
59
+ */
60
+ title: string;
61
+
62
+ /**
63
+ * Style property for the Animated.View wrapper, apply animations to this
64
+ */
65
+ style?: ViewStyle;
66
+
67
+ /**
68
+ * Style property for the native RCTMGLCallout container, set at your own risk.
69
+ */
70
+ containerStyle?: ViewStyle;
71
+
72
+ /**
73
+ * Style property for the content bubble.
74
+ */
75
+ contentStyle?: ViewStyle;
76
+
77
+ /**
78
+ * Style property for the triangle tip under the content.
79
+ */
80
+ tipStyle?: ViewStyle;
81
+
82
+ /**
83
+ * Style property for the title in the content bubble.
84
+ */
85
+ textStyle?: ViewStyle;
86
+ };
87
+
51
88
  /**
52
89
  * Callout that displays information about a selected annotation near the annotation.
53
90
  */
54
- class Callout extends React.PureComponent {
55
- static propTypes = {
56
- ...viewPropTypes,
57
-
58
- /**
59
- * String that gets displayed in the default callout.
60
- */
61
- title: PropTypes.string,
62
-
63
- /**
64
- * Style property for the Animated.View wrapper, apply animations to this
65
- */
66
- style: PropTypes.any,
67
-
68
- /**
69
- * Style property for the native RCTMGLCallout container, set at your own risk.
70
- */
71
- containerStyle: PropTypes.any,
72
-
73
- /**
74
- * Style property for the content bubble.
75
- */
76
- contentStyle: PropTypes.any,
77
-
78
- /**
79
- * Style property for the triangle tip under the content.
80
- */
81
- tipStyle: PropTypes.any,
82
-
83
- /**
84
- * Style property for the title in the content bubble.
85
- */
86
- textStyle: PropTypes.any,
87
- };
88
-
91
+ class Callout extends React.PureComponent<Props> {
89
92
  get _containerStyle() {
90
- return [
93
+ const style = [
91
94
  {
92
95
  position: 'absolute',
93
96
  zIndex: 999,
94
97
  backgroundColor: 'transparent',
95
- },
96
- this.props.containerStyle,
98
+ } as ViewStyle,
97
99
  ];
100
+
101
+ if (this.props.containerStyle) {
102
+ style.push(this.props.containerStyle);
103
+ }
104
+
105
+ return style;
98
106
  }
99
107
 
100
108
  get _hasChildren() {
101
109
  return React.Children.count(this.props.children) > 0;
102
110
  }
103
111
 
104
- _renderDefaultCallout() {
112
+ _renderDefaultCallout(): ReactNode {
105
113
  return (
106
114
  <Animated.View style={[styles.container, this.props.style]}>
107
115
  <View style={[styles.content, this.props.contentStyle]}>
@@ -114,7 +122,7 @@ class Callout extends React.PureComponent {
114
122
  );
115
123
  }
116
124
 
117
- _renderCustomCallout() {
125
+ _renderCustomCallout(): ReactNode {
118
126
  return (
119
127
  <Animated.View {...this.props} style={this.props.style}>
120
128
  {this.props.children}
@@ -134,6 +142,6 @@ class Callout extends React.PureComponent {
134
142
  }
135
143
  }
136
144
 
137
- const RCTMGLCallout = requireNativeComponent(NATIVE_MODULE_NAME, Callout);
145
+ const RCTMGLCallout = requireNativeComponent<NativeProps>(NATIVE_MODULE_NAME);
138
146
 
139
147
  export default Callout;
@@ -18,6 +18,11 @@ export type Props = {
18
18
  */
19
19
  id: string;
20
20
 
21
+ /**
22
+ * The id refers to en existing layer in the style. Does not create a new layer.
23
+ */
24
+ existing?: boolean;
25
+
21
26
  /**
22
27
  * The source from which to obtain the data to style.
23
28
  * If the source has not yet been added to the current style, the behavior is undefined.
@@ -15,10 +15,15 @@ export const NATIVE_MODULE_NAME = 'RCTMGLFillExtrusionLayer';
15
15
 
16
16
  export type Props = {
17
17
  /**
18
- * A string that uniquely identifies the source in the style to which it is added.
18
+ * A string that uniquely identifies the layer in the style to which it is added.
19
19
  */
20
20
  id: string;
21
21
 
22
+ /**
23
+ * The id refers to en existing layer in the style. Does not create a new layer.
24
+ */
25
+ existing?: boolean;
26
+
22
27
  /**
23
28
  * The source from which to obtain the data to style.
24
29
  * If the source has not yet been added to the current style, the behavior is undefined.
@@ -16,6 +16,11 @@ export type Props = {
16
16
  */
17
17
  id: string;
18
18
 
19
+ /**
20
+ * The id refers to en existing layer in the style. Does not create a new layer.
21
+ */
22
+ existing?: boolean;
23
+
19
24
  /**
20
25
  * The source from which to obtain the data to style.
21
26
  * If the source has not yet been added to the current style, the behavior is undefined.