@rnmapbox/maps 10.3.0-rc.0 → 10.3.1

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 (115) hide show
  1. package/android/src/main/java/com/rnmapbox/rnmbx/RNMBXPackage.kt +4 -0
  2. package/android/src/main/java/com/rnmapbox/rnmbx/components/annotation/RNMBXMarkerViewContent.kt +55 -0
  3. package/android/src/main/java/com/rnmapbox/rnmbx/components/annotation/RNMBXMarkerViewContentManager.kt +7 -2
  4. package/android/src/main/java/com/rnmapbox/rnmbx/components/annotation/RNMBXMarkerViewManager.kt +0 -2
  5. package/android/src/main/java/com/rnmapbox/rnmbx/components/location/RNMBXNativeUserLocationManager.kt +25 -24
  6. package/android/src/main/java/com/rnmapbox/rnmbx/components/mapview/NativeMapViewModule.kt +3 -2
  7. package/android/src/main/java/com/rnmapbox/rnmbx/components/mapview/RNMBXMapView.kt +57 -39
  8. package/android/src/main/java/com/rnmapbox/rnmbx/components/mapview/RNMBXMapViewManager.kt +0 -9
  9. package/android/src/main/java/com/rnmapbox/rnmbx/components/styles/RNMBXStyleFactory.kt +638 -0
  10. package/android/src/main/java/com/rnmapbox/rnmbx/components/styles/atmosphere/RNMBXAtmosphere.kt +4 -4
  11. package/android/src/main/java/com/rnmapbox/rnmbx/components/styles/atmosphere/RNMBXAtmosphereManager.kt +2 -1
  12. package/android/src/main/java/com/rnmapbox/rnmbx/components/styles/light/RNMBXLightManager.kt +2 -1
  13. package/android/src/main/java/com/rnmapbox/rnmbx/components/styles/rain/RNMBXRain.kt +83 -0
  14. package/android/src/main/java/com/rnmapbox/rnmbx/components/styles/rain/RNMBXRainManager.kt +40 -0
  15. package/android/src/main/java/com/rnmapbox/rnmbx/components/styles/snow/RNMBXSnow.kt +66 -0
  16. package/android/src/main/java/com/rnmapbox/rnmbx/components/styles/snow/RNMBXSnowManager.kt +40 -0
  17. package/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXSource.kt +2 -6
  18. package/android/src/main/java/com/rnmapbox/rnmbx/components/styles/terrain/RNMBXTerrainManager.kt +2 -1
  19. package/android/src/main/java/com/rnmapbox/rnmbx/events/FeatureClickEvent.java +5 -6
  20. package/android/src/main/java/com/rnmapbox/rnmbx/modules/RNMBXModule.kt +1 -0
  21. package/android/src/main/java/com/rnmapbox/rnmbx/utils/ConvertUtils.kt +0 -30
  22. package/android/src/main/java/com/rnmapbox/rnmbx/utils/extensions/Dynamic.kt +3 -1
  23. package/android/src/main/java/com/rnmapbox/rnmbx/utils/extensions/ReadableArray.kt +16 -14
  24. package/ios/RNMBX/RNMBXAtmosphereComponentView.mm +2 -1
  25. package/ios/RNMBX/RNMBXBackgroundLayerComponentView.mm +2 -1
  26. package/ios/RNMBX/RNMBXBridgeManager.h +8 -0
  27. package/ios/RNMBX/RNMBXBridgeManager.m +16 -0
  28. package/ios/RNMBX/RNMBXCircleLayerComponentView.mm +2 -1
  29. package/ios/RNMBX/RNMBXFillExtrusionLayerComponentView.mm +2 -1
  30. package/ios/RNMBX/RNMBXFillLayerComponentView.mm +2 -1
  31. package/ios/RNMBX/RNMBXHeatmapLayerComponentView.mm +2 -1
  32. package/ios/RNMBX/RNMBXHillshadeLayerComponentView.mm +2 -1
  33. package/ios/RNMBX/RNMBXImageModule.h +1 -0
  34. package/ios/RNMBX/RNMBXImageModule.mm +15 -2
  35. package/ios/RNMBX/RNMBXImageQueue.swift +9 -1
  36. package/ios/RNMBX/RNMBXImages.swift +4 -0
  37. package/ios/RNMBX/RNMBXImagesComponentView.mm +2 -1
  38. package/ios/RNMBX/RNMBXLightComponentView.mm +2 -1
  39. package/ios/RNMBX/RNMBXLineLayerComponentView.mm +2 -1
  40. package/ios/RNMBX/RNMBXMapViewModule.mm +1 -1
  41. package/ios/RNMBX/RNMBXModelLayerComponentView.mm +2 -1
  42. package/ios/RNMBX/RNMBXModule.swift +1 -0
  43. package/ios/RNMBX/RNMBXRain.swift +92 -0
  44. package/ios/RNMBX/RNMBXRainComponentView.h +14 -0
  45. package/ios/RNMBX/RNMBXRainComponentView.mm +80 -0
  46. package/ios/RNMBX/RNMBXRasterLayerComponentView.mm +2 -1
  47. package/ios/RNMBX/RNMBXRasterParticleLayerComponentView.mm +2 -1
  48. package/ios/RNMBX/RNMBXSkyLayerComponentView.mm +2 -1
  49. package/ios/RNMBX/RNMBXSnow.swift +76 -0
  50. package/ios/RNMBX/RNMBXSnowComponentView.h +14 -0
  51. package/ios/RNMBX/RNMBXSnowComponentView.mm +80 -0
  52. package/ios/RNMBX/RNMBXStyle.swift +415 -9
  53. package/ios/RNMBX/RNMBXStyleValue.swift +7 -1
  54. package/ios/RNMBX/RNMBXSymbolLayerComponentView.mm +2 -1
  55. package/ios/RNMBX/RNMBXTerrainComponentView.mm +2 -1
  56. package/lib/commonjs/plugin/install.md +2 -2
  57. package/lib/module/Mapbox.native.js +2 -0
  58. package/lib/module/Mapbox.native.js.map +1 -1
  59. package/lib/module/components/MapView.js +95 -113
  60. package/lib/module/components/MapView.js.map +1 -1
  61. package/lib/module/components/MarkerView.js +93 -76
  62. package/lib/module/components/MarkerView.js.map +1 -1
  63. package/lib/module/components/Rain.js +19 -0
  64. package/lib/module/components/Rain.js.map +1 -0
  65. package/lib/module/components/Snow.js +19 -0
  66. package/lib/module/components/Snow.js.map +1 -0
  67. package/lib/module/modules/offline/offlineManager.js +2 -12
  68. package/lib/module/modules/offline/offlineManager.js.map +1 -1
  69. package/lib/module/specs/RNMBXMarkerViewContentNativeComponent.ts +13 -1
  70. package/lib/module/specs/RNMBXRainNativeComponent.ts +13 -0
  71. package/lib/module/specs/RNMBXSnowNativeComponent.ts +13 -0
  72. package/lib/module/utils/styleMap.js +20 -0
  73. package/lib/module/utils/styleMap.js.map +1 -1
  74. package/lib/typescript/scripts/autogenHelpers/generateCodeWithEjs.d.mts +71 -2
  75. package/lib/typescript/scripts/autogenHelpers/generateCodeWithEjs.d.mts.map +1 -1
  76. package/lib/typescript/scripts/autogenHelpers/globals.d.mts +1 -1
  77. package/lib/typescript/scripts/autogenHelpers/globals.d.mts.map +1 -1
  78. package/lib/typescript/src/Mapbox.native.d.ts +3 -1
  79. package/lib/typescript/src/Mapbox.native.d.ts.map +1 -1
  80. package/lib/typescript/src/components/Callout.d.ts +3 -3
  81. package/lib/typescript/src/components/Camera.d.ts +2 -2
  82. package/lib/typescript/src/components/Camera.d.ts.map +1 -1
  83. package/lib/typescript/src/components/MapView.d.ts +53 -41
  84. package/lib/typescript/src/components/MapView.d.ts.map +1 -1
  85. package/lib/typescript/src/components/MarkerView.d.ts +10 -17
  86. package/lib/typescript/src/components/MarkerView.d.ts.map +1 -1
  87. package/lib/typescript/src/components/Rain.d.ts +17 -0
  88. package/lib/typescript/src/components/Rain.d.ts.map +1 -0
  89. package/lib/typescript/src/components/Snow.d.ts +8 -0
  90. package/lib/typescript/src/components/Snow.d.ts.map +1 -0
  91. package/lib/typescript/src/modules/offline/offlineManager.d.ts.map +1 -1
  92. package/lib/typescript/src/specs/RNMBXMarkerViewContentNativeComponent.d.ts +6 -0
  93. package/lib/typescript/src/specs/RNMBXMarkerViewContentNativeComponent.d.ts.map +1 -1
  94. package/lib/typescript/src/specs/RNMBXRainNativeComponent.d.ts +8 -0
  95. package/lib/typescript/src/specs/RNMBXRainNativeComponent.d.ts.map +1 -0
  96. package/lib/typescript/src/specs/RNMBXSnowNativeComponent.d.ts +8 -0
  97. package/lib/typescript/src/specs/RNMBXSnowNativeComponent.d.ts.map +1 -0
  98. package/lib/typescript/src/utils/MapboxStyles.d.ts +171 -1
  99. package/lib/typescript/src/utils/MapboxStyles.d.ts.map +1 -1
  100. package/lib/typescript/src/utils/styleMap.d.ts.map +1 -1
  101. package/package.json +12 -3
  102. package/plugin/install.md +2 -2
  103. package/setup-jest.js +1 -1
  104. package/src/Mapbox.native.ts +7 -1
  105. package/src/components/Camera.tsx +2 -2
  106. package/src/components/MapView.tsx +137 -154
  107. package/src/components/MarkerView.tsx +118 -95
  108. package/src/components/Rain.tsx +31 -0
  109. package/src/components/Snow.tsx +22 -0
  110. package/src/modules/offline/offlineManager.ts +2 -14
  111. package/src/specs/RNMBXMarkerViewContentNativeComponent.ts +13 -1
  112. package/src/specs/RNMBXRainNativeComponent.ts +13 -0
  113. package/src/specs/RNMBXSnowNativeComponent.ts +13 -0
  114. package/src/utils/MapboxStyles.ts +191 -0
  115. package/src/utils/styleMap.ts +22 -0
@@ -2,6 +2,7 @@ package com.rnmapbox.rnmbx.components.styles.atmosphere
2
2
 
3
3
  import com.facebook.react.bridge.Dynamic
4
4
  import com.facebook.react.uimanager.ThemedReactContext
5
+ import com.rnmapbox.rnmbx.utils.extensions.asMapOrNull
5
6
  import com.facebook.react.uimanager.ViewGroupManager
6
7
  import com.facebook.react.uimanager.ViewManagerDelegate
7
8
  import com.facebook.react.uimanager.annotations.ReactProp
@@ -30,7 +31,7 @@ class RNMBXAtmosphereManager : ViewGroupManager<RNMBXAtmosphere>(), RNMBXAtmosph
30
31
 
31
32
  @ReactProp(name = "reactStyle")
32
33
  override fun setReactStyle(atmosphere: RNMBXAtmosphere, reactStyle: Dynamic) {
33
- atmosphere.setReactStyle(reactStyle.asMap())
34
+ atmosphere.setReactStyle(reactStyle.asMapOrNull())
34
35
  }
35
36
 
36
37
  companion object {
@@ -2,6 +2,7 @@ package com.rnmapbox.rnmbx.components.styles.light
2
2
 
3
3
  import com.facebook.react.bridge.Dynamic
4
4
  import com.facebook.react.uimanager.ThemedReactContext
5
+ import com.rnmapbox.rnmbx.utils.extensions.asMapOrNull
5
6
  import com.facebook.react.uimanager.ViewGroupManager
6
7
  import com.facebook.react.uimanager.annotations.ReactProp
7
8
  import com.facebook.react.viewmanagers.RNMBXLightManagerInterface
@@ -18,7 +19,7 @@ class RNMBXLightManager : ViewGroupManager<RNMBXLight>(),
18
19
 
19
20
  @ReactProp(name = "reactStyle")
20
21
  override fun setReactStyle(light: RNMBXLight, reactStyle: Dynamic) {
21
- light.setReactStyle(reactStyle.asMap())
22
+ light.setReactStyle(reactStyle.asMapOrNull())
22
23
  }
23
24
 
24
25
  companion object {
@@ -0,0 +1,83 @@
1
+ package com.rnmapbox.rnmbx.components.styles.rain
2
+
3
+ import android.content.Context
4
+ import com.facebook.react.bridge.ReadableMap
5
+ import com.mapbox.maps.MapboxMap
6
+ import com.mapbox.maps.extension.style.precipitations.generated.Rain
7
+ import com.mapbox.maps.extension.style.precipitations.generated.removeRain
8
+ import com.rnmapbox.rnmbx.components.RemovalReason
9
+ import com.rnmapbox.rnmbx.components.mapview.RNMBXMapView
10
+ import com.rnmapbox.rnmbx.components.styles.RNMBXStyle
11
+ import com.rnmapbox.rnmbx.components.styles.RNMBXStyleFactory
12
+ import com.rnmapbox.rnmbx.components.styles.sources.AbstractSourceConsumer
13
+ import com.rnmapbox.rnmbx.utils.Logger
14
+
15
+ class RNMBXRain(context: Context?) : AbstractSourceConsumer(context) {
16
+ override var iD: String? = null
17
+ protected var mRain: Rain? = null
18
+
19
+ // beginregion RNMBXLayer
20
+ @JvmField
21
+ protected var mMap: MapboxMap? = null
22
+
23
+ @JvmField
24
+ protected var mReactStyle: ReadableMap? = null
25
+
26
+ fun setReactStyle(reactStyle: ReadableMap?) {
27
+ mReactStyle = reactStyle
28
+ if (mRain != null) {
29
+ addStyles()
30
+ }
31
+ }
32
+ // endregion RNMBXLayer
33
+
34
+ override fun addToMap(mapView: RNMBXMapView) {
35
+ super.addToMap(mapView)
36
+ mMap = mapView.getMapboxMap()
37
+ mapView.savedStyle?.let { warnIfMeasureLightUnavailable(it) }
38
+ val rain = makeRain()
39
+ mRain = rain
40
+ addStyles()
41
+ mapView.savedStyle?.let { rain.bindTo(it) }
42
+ }
43
+
44
+ private fun warnIfMeasureLightUnavailable(style: com.mapbox.maps.Style) {
45
+ val hasLights = style.getStyleLights().isNotEmpty()
46
+ if (hasLights) return
47
+
48
+ val affectedProps = listOf("color", "opacity", "vignetteColor")
49
+ val missingProps = affectedProps.filter { mReactStyle?.hasKey(it) != true }
50
+ if (missingProps.isEmpty()) return
51
+
52
+ Logger.w(
53
+ "RNMBXRain",
54
+ "The current style has no 3D lights, so measure-light(\"brightness\") " +
55
+ "expressions used in default rain ${missingProps.joinToString(", ")} will fail. " +
56
+ "Use a Standard style or set explicit values for: ${missingProps.joinToString(", ")}"
57
+ )
58
+ }
59
+
60
+ override fun removeFromMap(mapView: RNMBXMapView, reason: RemovalReason): Boolean {
61
+ mapView.savedStyle?.let { it.removeRain() }
62
+ mRain = null
63
+ mMap = null
64
+ return super.removeFromMap(mapView, reason)
65
+ }
66
+
67
+ fun makeRain(): Rain {
68
+ return Rain()
69
+ }
70
+
71
+ fun addStyles() {
72
+ mRain?.also {
73
+ RNMBXStyleFactory.setRainLayerStyle(
74
+ it, RNMBXStyle(
75
+ context, mReactStyle,
76
+ mMap!!
77
+ )
78
+ )
79
+ } ?: run {
80
+ Logger.e("RNMBXRain", "mRain is null")
81
+ }
82
+ }
83
+ }
@@ -0,0 +1,40 @@
1
+ package com.rnmapbox.rnmbx.components.styles.rain
2
+
3
+ import com.facebook.react.bridge.Dynamic
4
+ import com.facebook.react.uimanager.ThemedReactContext
5
+ import com.rnmapbox.rnmbx.utils.extensions.asMapOrNull
6
+ import com.facebook.react.uimanager.ViewGroupManager
7
+ import com.facebook.react.uimanager.ViewManagerDelegate
8
+ import com.facebook.react.uimanager.annotations.ReactProp
9
+ import com.facebook.react.viewmanagers.RNMBXRainManagerDelegate
10
+ import com.facebook.react.viewmanagers.RNMBXRainManagerInterface
11
+
12
+ class RNMBXRainManager : ViewGroupManager<RNMBXRain>(), RNMBXRainManagerInterface<RNMBXRain> {
13
+
14
+ private val mDelegate: ViewManagerDelegate<RNMBXRain>
15
+
16
+ init {
17
+ mDelegate = RNMBXRainManagerDelegate(this)
18
+ }
19
+
20
+ override fun getDelegate(): ViewManagerDelegate<RNMBXRain> {
21
+ return mDelegate
22
+ }
23
+
24
+ override fun getName(): String {
25
+ return REACT_CLASS
26
+ }
27
+
28
+ override fun createViewInstance(reactContext: ThemedReactContext): RNMBXRain {
29
+ return RNMBXRain(reactContext)
30
+ }
31
+
32
+ @ReactProp(name = "reactStyle")
33
+ override fun setReactStyle(rain: RNMBXRain, reactStyle: Dynamic) {
34
+ rain.setReactStyle(reactStyle.asMapOrNull())
35
+ }
36
+
37
+ companion object {
38
+ const val REACT_CLASS = "RNMBXRain"
39
+ }
40
+ }
@@ -0,0 +1,66 @@
1
+ package com.rnmapbox.rnmbx.components.styles.snow
2
+
3
+ import android.content.Context
4
+ import com.facebook.react.bridge.ReadableMap
5
+ import com.mapbox.maps.MapboxMap
6
+ import com.mapbox.maps.extension.style.precipitations.generated.Snow
7
+ import com.mapbox.maps.extension.style.precipitations.generated.removeSnow
8
+ import com.rnmapbox.rnmbx.components.RemovalReason
9
+ import com.rnmapbox.rnmbx.components.mapview.RNMBXMapView
10
+ import com.rnmapbox.rnmbx.components.styles.RNMBXStyle
11
+ import com.rnmapbox.rnmbx.components.styles.RNMBXStyleFactory
12
+ import com.rnmapbox.rnmbx.components.styles.sources.AbstractSourceConsumer
13
+ import com.rnmapbox.rnmbx.utils.Logger
14
+
15
+ class RNMBXSnow(context: Context?) : AbstractSourceConsumer(context) {
16
+ override var iD: String? = null
17
+ protected var mSnow: Snow? = null
18
+
19
+ // beginregion RNMBXLayer
20
+ @JvmField
21
+ protected var mMap: MapboxMap? = null
22
+
23
+ @JvmField
24
+ protected var mReactStyle: ReadableMap? = null
25
+
26
+ fun setReactStyle(reactStyle: ReadableMap?) {
27
+ mReactStyle = reactStyle
28
+ if (mSnow != null) {
29
+ addStyles()
30
+ }
31
+ }
32
+ // endregion RNMBXLayer
33
+
34
+ override fun addToMap(mapView: RNMBXMapView) {
35
+ super.addToMap(mapView)
36
+ mMap = mapView.getMapboxMap()
37
+ val snow = makeSnow()
38
+ mSnow = snow
39
+ addStyles()
40
+ mapView.savedStyle?.let { snow.bindTo(it) }
41
+ }
42
+
43
+ override fun removeFromMap(mapView: RNMBXMapView, reason: RemovalReason): Boolean {
44
+ mapView.savedStyle?.let { it.removeSnow() }
45
+ mSnow = null
46
+ mMap = null
47
+ return super.removeFromMap(mapView, reason)
48
+ }
49
+
50
+ fun makeSnow(): Snow {
51
+ return Snow()
52
+ }
53
+
54
+ fun addStyles() {
55
+ mSnow?.also {
56
+ RNMBXStyleFactory.setSnowLayerStyle(
57
+ it, RNMBXStyle(
58
+ context, mReactStyle,
59
+ mMap!!
60
+ )
61
+ )
62
+ } ?: run {
63
+ Logger.e("RNMBXSnow", "mSnow is null")
64
+ }
65
+ }
66
+ }
@@ -0,0 +1,40 @@
1
+ package com.rnmapbox.rnmbx.components.styles.snow
2
+
3
+ import com.facebook.react.bridge.Dynamic
4
+ import com.facebook.react.uimanager.ThemedReactContext
5
+ import com.rnmapbox.rnmbx.utils.extensions.asMapOrNull
6
+ import com.facebook.react.uimanager.ViewGroupManager
7
+ import com.facebook.react.uimanager.ViewManagerDelegate
8
+ import com.facebook.react.uimanager.annotations.ReactProp
9
+ import com.facebook.react.viewmanagers.RNMBXSnowManagerDelegate
10
+ import com.facebook.react.viewmanagers.RNMBXSnowManagerInterface
11
+
12
+ class RNMBXSnowManager : ViewGroupManager<RNMBXSnow>(), RNMBXSnowManagerInterface<RNMBXSnow> {
13
+
14
+ private val mDelegate: ViewManagerDelegate<RNMBXSnow>
15
+
16
+ init {
17
+ mDelegate = RNMBXSnowManagerDelegate(this)
18
+ }
19
+
20
+ override fun getDelegate(): ViewManagerDelegate<RNMBXSnow> {
21
+ return mDelegate
22
+ }
23
+
24
+ override fun getName(): String {
25
+ return REACT_CLASS
26
+ }
27
+
28
+ override fun createViewInstance(reactContext: ThemedReactContext): RNMBXSnow {
29
+ return RNMBXSnow(reactContext)
30
+ }
31
+
32
+ @ReactProp(name = "reactStyle")
33
+ override fun setReactStyle(snow: RNMBXSnow, reactStyle: Dynamic) {
34
+ snow.setReactStyle(reactStyle.asMapOrNull())
35
+ }
36
+
37
+ companion object {
38
+ const val REACT_CLASS = "RNMBXSnow"
39
+ }
40
+ }
@@ -6,22 +6,18 @@ import com.mapbox.maps.extension.style.sources.addSource
6
6
  import com.rnmapbox.rnmbx.components.AbstractMapFeature
7
7
  import com.rnmapbox.rnmbx.components.mapview.RNMBXMapView
8
8
  import com.mapbox.maps.MapboxMap
9
- import com.rnmapbox.rnmbx.components.styles.sources.AbstractSourceConsumer
10
9
  import com.facebook.react.bridge.ReadableMap
11
- import com.rnmapbox.rnmbx.components.styles.sources.RNMBXSource
12
- import android.graphics.PointF
13
10
  import android.view.View
14
11
  import com.facebook.react.common.MapBuilder
15
12
  import com.mapbox.geojson.Feature
13
+ import com.mapbox.maps.ScreenCoordinate
16
14
  import com.mapbox.maps.Style
17
15
  import com.mapbox.maps.extension.style.StyleContract
18
16
  import com.mapbox.maps.extension.style.sources.Source
19
17
  import com.rnmapbox.rnmbx.components.RemovalReason
20
- import com.rnmapbox.rnmbx.components.styles.sources.RNMBXSource.OnPressEvent
21
18
  import com.rnmapbox.rnmbx.utils.LatLng
22
19
  import com.rnmapbox.rnmbx.utils.Logger
23
20
  import java.lang.ClassCastException
24
- import java.util.ArrayList
25
21
  import java.util.HashMap
26
22
 
27
23
  data class FeatureInfo(val feature: AbstractMapFeature?, var added: Boolean) {
@@ -221,7 +217,7 @@ abstract class RNMBXSource<T : Source?>(context: Context?) : AbstractMapFeature(
221
217
 
222
218
 
223
219
  abstract fun makeSource(): T
224
- class OnPressEvent(var features: List<Feature>, var latLng: LatLng, var screenPoint: PointF)
220
+ class OnPressEvent(var features: List<Feature>, var latLng: LatLng, var screenPoint: ScreenCoordinate)
225
221
 
226
222
  abstract fun onPress(event: OnPressEvent?)
227
223
 
@@ -2,6 +2,7 @@ package com.rnmapbox.rnmbx.components.styles.terrain
2
2
 
3
3
  import com.facebook.react.bridge.Dynamic
4
4
  import com.facebook.react.uimanager.ThemedReactContext
5
+ import com.rnmapbox.rnmbx.utils.extensions.asMapOrNull
5
6
  import com.facebook.react.uimanager.ViewGroupManager
6
7
  import com.facebook.react.uimanager.annotations.ReactProp
7
8
  import com.facebook.react.viewmanagers.RNMBXTerrainManagerInterface
@@ -23,7 +24,7 @@ class RNMBXTerrainManager : ViewGroupManager<RNMBXTerrain>(),
23
24
 
24
25
  @ReactProp(name = "reactStyle")
25
26
  override fun setReactStyle(terrain: RNMBXTerrain, reactStyle: Dynamic) {
26
- terrain.setReactStyle(reactStyle.asMap())
27
+ terrain.setReactStyle(reactStyle.asMapOrNull())
27
28
  }
28
29
 
29
30
  companion object {
@@ -1,16 +1,15 @@
1
1
  package com.rnmapbox.rnmbx.events;
2
2
 
3
- import android.graphics.PointF;
4
3
  import android.view.View;
5
4
 
6
5
  import com.facebook.react.bridge.Arguments;
7
6
  import com.facebook.react.bridge.WritableArray;
8
7
  import com.facebook.react.bridge.WritableMap;
9
8
  import com.mapbox.geojson.Feature;
9
+ import com.mapbox.maps.ScreenCoordinate;
10
10
  import com.rnmapbox.rnmbx.components.styles.sources.RNMBXSource;
11
11
  import com.rnmapbox.rnmbx.events.constants.EventKeys;
12
12
  import com.rnmapbox.rnmbx.events.constants.EventTypes;
13
- import com.rnmapbox.rnmbx.utils.ConvertUtils;
14
13
  import com.rnmapbox.rnmbx.utils.GeoJSONUtils;
15
14
  import com.rnmapbox.rnmbx.utils.LatLng;
16
15
 
@@ -24,9 +23,9 @@ public class FeatureClickEvent extends AbstractEvent {
24
23
  private String mEventKey;
25
24
  private List<Feature> mFeatures;
26
25
  private LatLng mLatLng;
27
- private PointF mPoint;
26
+ private ScreenCoordinate mPoint;
28
27
 
29
- public FeatureClickEvent(View view, String eventKey, String eventType, List<Feature> features, LatLng latLng, PointF point) {
28
+ public FeatureClickEvent(View view, String eventKey, String eventType, List<Feature> features, LatLng latLng, ScreenCoordinate point) {
30
29
  super(view, eventType);
31
30
  mFeatures = features;
32
31
  mEventKey = eventKey;
@@ -55,8 +54,8 @@ public class FeatureClickEvent extends AbstractEvent {
55
54
  map.putMap("coordinates", coordinates);
56
55
 
57
56
  WritableMap point = Arguments.createMap();
58
- point.putDouble("x", mPoint.x);
59
- point.putDouble("y", mPoint.y);
57
+ point.putDouble("x", mPoint.getX());
58
+ point.putDouble("y", mPoint.getY());
60
59
  map.putMap("point", point);
61
60
 
62
61
  return map;
@@ -114,6 +114,7 @@ class RNMBXModule(private val mReactContext: ReactApplicationContext) : ReactCon
114
114
  val locationModuleCallbackNames: MutableMap<String, String> = HashMap()
115
115
  locationModuleCallbackNames["Update"] = RNMBXLocationModule.LOCATION_UPDATE
116
116
  return MapBuilder.builder<String, Any>()
117
+ // Deprecated: means v10 or later, always true. Will be removed in next major version.
117
118
  .put("MapboxV10", true)
118
119
  .put("StyleURL", styleURLS)
119
120
  .put("EventTypes", eventTypes)
@@ -1,7 +1,5 @@
1
1
  package com.rnmapbox.rnmbx.utils
2
2
 
3
- import android.graphics.PointF
4
- import android.graphics.RectF
5
3
  import android.util.Log
6
4
  import com.facebook.react.bridge.Arguments
7
5
  import com.facebook.react.bridge.NoSuchKeyException
@@ -172,34 +170,6 @@ object ConvertUtils {
172
170
  return list
173
171
  }
174
172
 
175
- fun toPointF(array: ReadableArray?): PointF {
176
- val pointF = PointF()
177
-
178
- if (array == null) {
179
- return pointF
180
- }
181
-
182
- pointF.set(array.getDouble(0).toFloat(), array.getDouble(1).toFloat())
183
- return pointF
184
- }
185
-
186
- // returns null if array is null
187
- fun toRectF(array: ReadableArray?): RectF? {
188
- val rectF = RectF()
189
-
190
- if (array == null || array.size() == 0) {
191
- return null
192
- }
193
-
194
- rectF.set(
195
- array.getDouble(3).toFloat(),
196
- array.getDouble(0).toFloat(),
197
- array.getDouble(1).toFloat(),
198
- array.getDouble(2).toFloat()
199
- )
200
- return rectF
201
- }
202
-
203
173
  fun getDouble(key: String, map: ReadableMap, defaultValue: Double): Double {
204
174
  var value = defaultValue
205
175
 
@@ -107,4 +107,6 @@ fun Dynamic.asStringOrNull(): String? {
107
107
  } else {
108
108
  asString()
109
109
  }
110
- }
110
+ }
111
+
112
+ fun Dynamic.asMapOrNull(): ReadableMap? = if (isNull) null else asMap()
@@ -1,17 +1,15 @@
1
1
  package com.rnmapbox.rnmbx.utils.extensions
2
2
 
3
- import android.graphics.RectF
4
3
  import com.facebook.react.bridge.ReadableArray
5
4
  import com.facebook.react.bridge.ReadableType
6
5
  import com.google.gson.JsonArray
7
6
  import com.google.gson.JsonElement
8
7
  import com.mapbox.geojson.Point
8
+ import com.mapbox.maps.ScreenBox
9
9
  import com.mapbox.maps.ScreenCoordinate
10
- import com.rnmapbox.rnmbx.utils.ConvertUtils
11
10
  import com.rnmapbox.rnmbx.utils.Logger
12
- import org.json.JSONArray
13
- import java.lang.Float.max
14
- import java.lang.Float.min
11
+ import kotlin.math.max
12
+ import kotlin.math.min
15
13
 
16
14
  fun ReadableArray.toCoordinate() : Point {
17
15
  if (this.size() != 2) {
@@ -25,20 +23,24 @@ fun ReadableArray.toCoordinate() : Point {
25
23
 
26
24
  fun ReadableArray.toScreenCoordinate() : ScreenCoordinate {
27
25
  if (this.size() != 2) {
28
- Logger.e("ReadableArray.toCoordinate","Cannot convert $this to point, 2 coordinates are required")
26
+ Logger.e("ReadableArray.toScreenCoordinate","Cannot convert $this to point, 2 coordinates are required")
29
27
  }
30
28
  return ScreenCoordinate(getDouble(0), getDouble(1))
31
29
  }
32
30
 
33
- fun ReadableArray.toRectF() : RectF? {
34
- if (size() != 4) {
35
- return null;
31
+ fun ReadableArray.toScreenBox() : ScreenBox {
32
+ if (this.size() != 4) {
33
+ Logger.e("ReadableArray.toScreenBox","Cannot convert $this to box, 4 coordinates are required")
36
34
  }
37
- return RectF(
38
- min(getDouble(3).toFloat(), getDouble(1).toFloat()),
39
- min(getDouble(0).toFloat(), getDouble(2).toFloat()),
40
- max(getDouble(3).toFloat(), getDouble(1).toFloat()),
41
- max(getDouble(0).toFloat(), getDouble(2).toFloat())
35
+
36
+ val top = getDouble(0)
37
+ val left = getDouble(1)
38
+ val bottom = getDouble(2)
39
+ val right = getDouble(3)
40
+
41
+ return ScreenBox(
42
+ ScreenCoordinate(min(left, right), min(top, bottom)),
43
+ ScreenCoordinate(max(left, right), max(top, bottom))
42
44
  )
43
45
  }
44
46
 
@@ -3,6 +3,7 @@
3
3
  #import "RNMBXFabricHelpers.h"
4
4
 
5
5
  #import <React/RCTBridge+Private.h>
6
+ #import "RNMBXBridgeManager.h"
6
7
  #import <React/RCTConversions.h>
7
8
  #import <React/RCTFabricComponentsPlugins.h>
8
9
 
@@ -40,7 +41,7 @@ using namespace facebook::react;
40
41
  - (void)prepareView
41
42
  {
42
43
  _view = [[RNMBXAtmosphere alloc] init];
43
- _view.bridge = [RCTBridge currentBridge];
44
+ _view.bridge = [RNMBXBridgeManager currentBridge];
44
45
 
45
46
  self.contentView = _view;
46
47
  }
@@ -3,6 +3,7 @@
3
3
  #import "RNMBXFabricHelpers.h"
4
4
 
5
5
  #import <React/RCTBridge+Private.h>
6
+ #import "RNMBXBridgeManager.h"
6
7
  #import <React/RCTConversions.h>
7
8
  #import <React/RCTFabricComponentsPlugins.h>
8
9
 
@@ -40,7 +41,7 @@ using namespace facebook::react;
40
41
  - (void)prepareView
41
42
  {
42
43
  _view = [[RNMBXBackgroundLayer alloc] init];
43
- _view.bridge = [RCTBridge currentBridge];
44
+ _view.bridge = [RNMBXBridgeManager currentBridge];
44
45
  self.contentView = _view;
45
46
  }
46
47
 
@@ -0,0 +1,8 @@
1
+ #import <React/RCTBridge.h>
2
+
3
+ @interface RNMBXBridgeManager : NSObject
4
+
5
+ + (void)setBridge:(RCTBridge *)bridge;
6
+ + (RCTBridge *)currentBridge;
7
+
8
+ @end
@@ -0,0 +1,16 @@
1
+ #import "RNMBXBridgeManager.h"
2
+ #import <React/RCTBridge+Private.h>
3
+
4
+ static __weak RCTBridge *_rnmbxBridge = nil;
5
+
6
+ @implementation RNMBXBridgeManager
7
+
8
+ + (void)setBridge:(RCTBridge *)bridge {
9
+ _rnmbxBridge = bridge;
10
+ }
11
+
12
+ + (RCTBridge *)currentBridge {
13
+ return [RCTBridge currentBridge] ?: _rnmbxBridge;
14
+ }
15
+
16
+ @end
@@ -5,6 +5,7 @@
5
5
  #import <React/RCTConversions.h>
6
6
  #import <React/RCTFabricComponentsPlugins.h>
7
7
  #import <React/RCTBridge+Private.h>
8
+ #import "RNMBXBridgeManager.h"
8
9
 
9
10
  #import <react/renderer/components/rnmapbox_maps_specs/ComponentDescriptors.h>
10
11
  #import <react/renderer/components/rnmapbox_maps_specs/EventEmitters.h>
@@ -40,7 +41,7 @@ using namespace facebook::react;
40
41
  - (void)prepareView
41
42
  {
42
43
  _view = [[RNMBXCircleLayer alloc] init];
43
- _view.bridge = [RCTBridge currentBridge];
44
+ _view.bridge = [RNMBXBridgeManager currentBridge];
44
45
  self.contentView = _view;
45
46
  }
46
47
 
@@ -5,6 +5,7 @@
5
5
  #import <React/RCTConversions.h>
6
6
  #import <React/RCTFabricComponentsPlugins.h>
7
7
  #import <React/RCTBridge+Private.h>
8
+ #import "RNMBXBridgeManager.h"
8
9
 
9
10
  #import <react/renderer/components/rnmapbox_maps_specs/ComponentDescriptors.h>
10
11
  #import <react/renderer/components/rnmapbox_maps_specs/EventEmitters.h>
@@ -40,7 +41,7 @@ using namespace facebook::react;
40
41
  - (void)prepareView
41
42
  {
42
43
  _view = [[RNMBXFillExtrusionLayer alloc] init];
43
- _view.bridge = [RCTBridge currentBridge];
44
+ _view.bridge = [RNMBXBridgeManager currentBridge];
44
45
  self.contentView = _view;
45
46
  }
46
47
 
@@ -5,6 +5,7 @@
5
5
  #import <React/RCTConversions.h>
6
6
  #import <React/RCTFabricComponentsPlugins.h>
7
7
  #import <React/RCTBridge+Private.h>
8
+ #import "RNMBXBridgeManager.h"
8
9
 
9
10
  #import <react/renderer/components/rnmapbox_maps_specs/ComponentDescriptors.h>
10
11
  #import <react/renderer/components/rnmapbox_maps_specs/EventEmitters.h>
@@ -40,7 +41,7 @@ using namespace facebook::react;
40
41
  - (void)prepareView
41
42
  {
42
43
  _view = [[RNMBXFillLayer alloc] init];
43
- _view.bridge = [RCTBridge currentBridge];
44
+ _view.bridge = [RNMBXBridgeManager currentBridge];
44
45
  self.contentView = _view;
45
46
  }
46
47
 
@@ -5,6 +5,7 @@
5
5
  #import <React/RCTConversions.h>
6
6
  #import <React/RCTFabricComponentsPlugins.h>
7
7
  #import <React/RCTBridge+Private.h>
8
+ #import "RNMBXBridgeManager.h"
8
9
 
9
10
  #import <react/renderer/components/rnmapbox_maps_specs/ComponentDescriptors.h>
10
11
  #import <react/renderer/components/rnmapbox_maps_specs/EventEmitters.h>
@@ -40,7 +41,7 @@ using namespace facebook::react;
40
41
  - (void)prepareView
41
42
  {
42
43
  _view = [[RNMBXHeatmapLayer alloc] init];
43
- _view.bridge = [RCTBridge currentBridge];
44
+ _view.bridge = [RNMBXBridgeManager currentBridge];
44
45
  self.contentView = _view;
45
46
  }
46
47
  #pragma mark - RCTComponentViewProtocol
@@ -5,6 +5,7 @@
5
5
  #import <React/RCTConversions.h>
6
6
  #import <React/RCTFabricComponentsPlugins.h>
7
7
  #import <React/RCTBridge+Private.h>
8
+ #import "RNMBXBridgeManager.h"
8
9
 
9
10
  #import <react/renderer/components/rnmapbox_maps_specs/ComponentDescriptors.h>
10
11
  #import <react/renderer/components/rnmapbox_maps_specs/EventEmitters.h>
@@ -40,7 +41,7 @@ using namespace facebook::react;
40
41
  - (void)prepareView
41
42
  {
42
43
  _view = [[RNMBXHillshadeLayer alloc] init];
43
- _view.bridge = [RCTBridge currentBridge];
44
+ _view.bridge = [RNMBXBridgeManager currentBridge];
44
45
  self.contentView = _view;
45
46
  }
46
47
 
@@ -14,3 +14,4 @@
14
14
  @end
15
15
 
16
16
  #endif
17
+
@@ -4,15 +4,28 @@
4
4
 
5
5
  #import "RNMBXImageModule.h"
6
6
  #import "RNMBXImageComponentView.h"
7
+ #import "RNMBXBridgeManager.h"
7
8
 
8
9
  #import "rnmapbox_maps-Swift.pre.h"
9
10
 
10
- @implementation RNMBXImageModule
11
+ @implementation RNMBXImageModule {
12
+ id _bridgeBacking;
13
+ }
11
14
 
12
15
  RCT_EXPORT_MODULE();
13
16
 
14
17
  @synthesize viewRegistry_DEPRECATED = _viewRegistry_DEPRECATED;
15
- @synthesize bridge = _bridge;
18
+
19
+ - (void)setBridge:(RCTBridge *)bridge {
20
+ _bridgeBacking = bridge;
21
+ if (bridge != nil) {
22
+ [RNMBXBridgeManager setBridge:bridge];
23
+ }
24
+ }
25
+
26
+ - (RCTBridge *)bridge {
27
+ return _bridgeBacking;
28
+ }
16
29
 
17
30
  - (dispatch_queue_t)methodQueue
18
31
  {