@rnmapbox/maps 10.2.4 → 10.2.6

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 (21) hide show
  1. package/android/src/main/java/com/rnmapbox/rnmbx/components/mapview/RNMBXMapView.kt +4 -4
  2. package/android/src/main/java/com/rnmapbox/rnmbx/components/styles/RNMBXStyle.kt +1 -1
  3. package/android/src/main/java/com/rnmapbox/rnmbx/components/styles/RNMBXStyleFactory.kt +0 -1
  4. package/android/src/main/java/com/rnmapbox/rnmbx/components/styles/RNMBXStyleValue.kt +6 -2
  5. package/android/src/main/java/com/rnmapbox/rnmbx/utils/ConvertUtils.kt +239 -0
  6. package/android/src/main/java/com/rnmapbox/rnmbx/utils/GeoJSONUtils.kt +5 -2
  7. package/android/src/main/mapbox-v11-compat/v10/com/rnmapbox/rnmbx/v11compat/StyleFactory.kt +29 -0
  8. package/android/src/test/kotlin/com/rnmapbox/rnmbx/components/styles/RNMBXStyleValueTest.kt +2 -2
  9. package/ios/RNMBX/RNMBXCustomLocationProvider.swift +4 -1
  10. package/ios/RNMBX/RNMBXCustomLocationProviderComponentView.mm +12 -2
  11. package/ios/RNMBX/RNMBXFabricPropConvert.h +12 -4
  12. package/ios/RNMBX/RNMBXFabricPropConvert.mm +4 -0
  13. package/ios/RNMBX/RNMBXMapViewComponentView.mm +2 -0
  14. package/ios/RNMBX/RNMBXPointAnnotationComponentView.mm +12 -20
  15. package/lib/module/components/MapView.js +1 -1
  16. package/lib/typescript/src/components/MapView.d.ts +1 -1
  17. package/package.json +1 -1
  18. package/src/components/MapView.tsx +1 -1
  19. package/android/src/main/java/com/rnmapbox/rnmbx/utils/ConvertUtils.java +0 -253
  20. package/android/src/main/mapbox-v11-compat/v10/com/rnmapbox/rnmbx/v11compat/Layers.kt +0 -35
  21. package/android/src/main/mapbox-v11-compat/v11/com/rnmapbox/rnmbx/v11compat/Layers.kt +0 -1
@@ -937,7 +937,7 @@ open class RNMBXMapView(private val mContext: Context, var mManager: RNMBXMapVie
937
937
  }
938
938
 
939
939
  fun queryRenderedFeaturesInRect(rect: RectF?, filter: Expression?, layerIDs: List<String>?, response: CommandResponse) {
940
- val size = mMap!!.getMapOptions().size
940
+ val size = mMap.getMapOptions().size
941
941
  val screenBox = if (rect == null) ScreenBox(ScreenCoordinate(0.0, 0.0), ScreenCoordinate(size?.width!!.toDouble(), size?.height!!.toDouble())) else ScreenBox(
942
942
  ScreenCoordinate(rect.right.toDouble(), rect.bottom.toDouble() ),
943
943
  ScreenCoordinate(rect.left.toDouble(), rect.top.toDouble()),
@@ -962,7 +962,7 @@ open class RNMBXMapView(private val mContext: Context, var mManager: RNMBXMapVie
962
962
  }
963
963
 
964
964
  fun querySourceFeatures(sourceId: String, filter: Expression?, sourceLayerIDs: List<String>?, response: CommandResponse) {
965
- mMap?.querySourceFeatures(
965
+ mMap.querySourceFeatures(
966
966
  sourceId,
967
967
  SourceQueryOptions(sourceLayerIDs, (filter ?: Value.nullValue()) as Value),
968
968
  ) { features ->
@@ -982,7 +982,7 @@ open class RNMBXMapView(private val mContext: Context, var mManager: RNMBXMapVie
982
982
  }
983
983
 
984
984
  fun getVisibleBounds(response: CommandResponse) {
985
- val bounds = mMap!!.coordinateBoundsForCamera(mMap!!.cameraState.toCameraOptions())
985
+ val bounds = mMap.coordinateBoundsForCamera(mMap.cameraState.toCameraOptions())
986
986
 
987
987
  response.success {
988
988
  it.putArray("visibleBounds", bounds.toReadableArray())
@@ -1009,7 +1009,7 @@ open class RNMBXMapView(private val mContext: Context, var mManager: RNMBXMapVie
1009
1009
  }
1010
1010
 
1011
1011
  fun queryTerrainElevation(longitude: Double, latitude: Double, response: CommandResponse) {
1012
- val result = mMap?.getElevation(Point.fromLngLat(longitude, latitude))
1012
+ val result = mMap.getElevation(Point.fromLngLat(longitude, latitude))
1013
1013
 
1014
1014
  if (result != null) {
1015
1015
  response.success {
@@ -32,7 +32,7 @@ class RNMBXStyle(private val mContext: Context, reactStyle: ReadableMap?, map: M
32
32
  fun getStyleValueForKey(styleKey: String): RNMBXStyleValue {
33
33
  val styleValueConfig = mReactStyle!!.getMap(styleKey)
34
34
  if (styleValueConfig != null) {
35
- return RNMBXStyleValue(styleValueConfig)
35
+ return RNMBXStyleValue(styleKey, styleValueConfig)
36
36
  } else {
37
37
  Logger.e("RNMBXStyle", "Value for ${styleKey} not found")
38
38
  throw Exception("RNMBXStyle - Value for ${styleKey} not found")
@@ -28,7 +28,6 @@ import com.rnmapbox.rnmbx.utils.DownloadMapImageTask.OnAllImagesLoaded
28
28
  import com.rnmapbox.rnmbx.utils.Logger
29
29
 
30
30
  import com.rnmapbox.rnmbx.v11compat.light.*;
31
- import com.rnmapbox.rnmbx.v11compat.layers.*;
32
31
  import com.rnmapbox.rnmbx.v11compat.stylefactory.*;
33
32
 
34
33
  import java.util.List;
@@ -13,8 +13,9 @@ import com.rnmapbox.rnmbx.utils.ExpressionParser
13
13
  import com.rnmapbox.rnmbx.utils.Logger
14
14
  import java.util.ArrayList
15
15
 
16
- class RNMBXStyleValue(config: ReadableMap) {
16
+ class RNMBXStyleValue(key: String?, config: ReadableMap) {
17
17
  val type: String?
18
+ val key: String?
18
19
  private var isExpression = false
19
20
  private var mExpression: Expression? = null
20
21
  private val mPayload: ReadableMap?
@@ -202,6 +203,7 @@ class RNMBXStyleValue(config: ReadableMap) {
202
203
  }
203
204
 
204
205
  init {
206
+ this.key = key
205
207
  type = config.getString("styletype")
206
208
  mPayload = config.getMap("stylevalue")
207
209
  isAddImage = false
@@ -231,7 +233,9 @@ class RNMBXStyleValue(config: ReadableMap) {
231
233
  val dynamic = mPayload!!.getDynamic("value")
232
234
  if (isExpression(dynamic)) {
233
235
  isExpression = true
234
- mExpression = ExpressionParser.fromTyped(mPayload)
236
+ Logger.logged("$key ExpressionParser.fromTyped") {
237
+ mExpression = ExpressionParser.fromTyped(mPayload)
238
+ }
235
239
  }
236
240
  }
237
241
  }
@@ -0,0 +1,239 @@
1
+ package com.rnmapbox.rnmbx.utils
2
+
3
+ import android.graphics.PointF
4
+ import android.graphics.RectF
5
+ import android.util.Log
6
+ import com.facebook.react.bridge.Arguments
7
+ import com.facebook.react.bridge.NoSuchKeyException
8
+ import com.facebook.react.bridge.ReadableArray
9
+ import com.facebook.react.bridge.ReadableMap
10
+ import com.facebook.react.bridge.ReadableType
11
+ import com.facebook.react.bridge.WritableArray
12
+ import com.facebook.react.bridge.WritableMap
13
+ import com.google.gson.JsonArray
14
+ import com.google.gson.JsonElement
15
+ import com.google.gson.JsonObject
16
+ import com.google.gson.JsonPrimitive
17
+ import java.text.NumberFormat
18
+ import java.text.ParseException
19
+
20
+ object ConvertUtils {
21
+ const val LOG_TAG: String = "ConvertUtils"
22
+
23
+ fun toJsonObject(map: ReadableMap?): JsonObject? {
24
+ if (map == null) return null
25
+ val result = JsonObject()
26
+ val it = map.keySetIterator()
27
+
28
+ while (it.hasNextKey()) {
29
+ val key = it.nextKey()
30
+ when (map.getType(key)) {
31
+ ReadableType.Map -> result.add(key, toJsonObject(map.getMap(key)))
32
+ ReadableType.Array -> result.add(key, toJsonArray(map.getArray(key)))
33
+ ReadableType.Null -> result.add(key, null)
34
+ ReadableType.Number -> result.addProperty(key, map.getDouble(key))
35
+ ReadableType.String -> result.addProperty(key, map.getString(key))
36
+ ReadableType.Boolean -> result.addProperty(key, map.getBoolean(key))
37
+ }
38
+ }
39
+ return result
40
+ }
41
+
42
+ @JvmStatic
43
+ fun toJsonArray(array: ReadableArray?): JsonArray? {
44
+ if (array == null) return null
45
+ val result = JsonArray(array.size())
46
+ for (i in 0..<array.size()) {
47
+ when (array.getType(i)) {
48
+ ReadableType.Map -> result.add(toJsonObject(array.getMap(i)))
49
+ ReadableType.Array -> result.add(toJsonArray(array.getArray(i)))
50
+ ReadableType.Null -> result.add(null as JsonElement?)
51
+ ReadableType.Number -> result.add(array.getDouble(i))
52
+ ReadableType.String -> result.add(array.getString(i))
53
+ ReadableType.Boolean -> result.add(array.getBoolean(i))
54
+ }
55
+ }
56
+ return result
57
+ }
58
+
59
+ @JvmStatic
60
+ fun typedToJsonElement(map: ReadableMap?): JsonElement? {
61
+ if (map == null) return null
62
+
63
+ val type = map.getString("type")
64
+
65
+ if (type == ExpressionParser.TYPE_MAP) {
66
+ val result = JsonObject()
67
+
68
+ val keyValues = map.getArray("value")
69
+ for (i in 0..<keyValues!!.size()) {
70
+ val keyValue = keyValues.getArray(i)
71
+ val key = keyValue!!.getMap(0)!!.getString("value")
72
+
73
+ result.add(key, typedToJsonElement(keyValue.getMap(1)))
74
+ }
75
+ return result
76
+ } else if (type == ExpressionParser.TYPE_ARRAY) {
77
+ val arrayValue = map.getArray("value")
78
+ val result = JsonArray(arrayValue!!.size())
79
+ for (i in 0..<arrayValue.size()) {
80
+ result.add(typedToJsonElement(arrayValue.getMap(i)))
81
+ }
82
+ return result
83
+ } else if (type == ExpressionParser.TYPE_BOOL) {
84
+ return JsonPrimitive(map.getBoolean("value"))
85
+ } else if (type == ExpressionParser.TYPE_NUMBER) {
86
+ return JsonPrimitive(map.getDouble("value"))
87
+ } else if (type == ExpressionParser.TYPE_STRING) {
88
+ return JsonPrimitive(map.getString("value"))
89
+ } else {
90
+ throw RuntimeException(String.format("Unrecognized type {}", map.getString("type")))
91
+ }
92
+ }
93
+
94
+ fun toWritableArray(array: JsonArray): WritableArray {
95
+ val writableArray = Arguments.createArray()
96
+
97
+ for (i in 0..<array.size()) {
98
+ val element = array.get(i)
99
+
100
+ if (element.isJsonArray()) {
101
+ writableArray.pushArray(toWritableArray(element.getAsJsonArray()))
102
+ } else if (element.isJsonObject()) {
103
+ writableArray.pushMap(toWritableMap(element.getAsJsonObject()))
104
+ } else if (element.isJsonPrimitive()) {
105
+ val primitive = element.getAsJsonPrimitive()
106
+
107
+ if (primitive.isBoolean()) {
108
+ writableArray.pushBoolean(primitive.getAsBoolean())
109
+ } else if (primitive.isNumber()) {
110
+ writableArray.pushDouble(primitive.getAsDouble())
111
+ } else {
112
+ writableArray.pushString(primitive.getAsString())
113
+ }
114
+ }
115
+ }
116
+
117
+ return writableArray
118
+ }
119
+
120
+ fun toWritableMap(inObject: JsonObject): WritableMap {
121
+ val map = Arguments.createMap()
122
+
123
+ for (entry in inObject.entrySet()) {
124
+ val propName = entry.key
125
+ val jsonElement = entry.value
126
+
127
+ if (jsonElement.isJsonPrimitive()) {
128
+ val primitive = jsonElement.getAsJsonPrimitive()
129
+
130
+ if (primitive.isBoolean()) {
131
+ map.putBoolean(propName, primitive.getAsBoolean())
132
+ } else if (primitive.isNumber()) {
133
+ map.putDouble(propName, primitive.getAsDouble())
134
+ } else {
135
+ map.putString(propName, primitive.getAsString())
136
+ }
137
+ } else if (jsonElement.isJsonArray()) {
138
+ map.putArray(propName, toWritableArray(jsonElement.getAsJsonArray()))
139
+ } else if (jsonElement.isJsonObject()) {
140
+ map.putMap(propName, toWritableMap(jsonElement.getAsJsonObject()))
141
+ }
142
+ }
143
+
144
+ return map
145
+ }
146
+
147
+ fun getObjectFromString(str: String): Any? {
148
+ val numberFormat = NumberFormat.getNumberInstance()
149
+
150
+ try {
151
+ return numberFormat.parse(str)
152
+ } catch (e: ParseException) {
153
+ // ignore we're just figuring out what type this is
154
+ }
155
+
156
+ return str
157
+ }
158
+
159
+ fun toStringList(array: ReadableArray?): MutableList<String> {
160
+ val list: MutableList<String> = ArrayList<String>()
161
+
162
+ if (array == null) {
163
+ return list
164
+ }
165
+
166
+ for (i in 0..<array.size()) {
167
+ array.getString(i)?.let {
168
+ list.add(it)
169
+ }
170
+ }
171
+
172
+ return list
173
+ }
174
+
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
+ fun getDouble(key: String, map: ReadableMap, defaultValue: Double): Double {
204
+ var value = defaultValue
205
+
206
+ try {
207
+ value = map.getDouble(key)
208
+ } catch (e: NoSuchKeyException) {
209
+ // key not found use default value
210
+ Log.d(
211
+ LOG_TAG,
212
+ String.format("No key found for %s, using default value %f", key, defaultValue)
213
+ )
214
+ }
215
+
216
+ return value
217
+ }
218
+
219
+ fun getString(key: String, map: ReadableMap, defaultValue: String): String {
220
+ var value = defaultValue
221
+
222
+ try {
223
+ map.getString(key)?.let {
224
+ value = it
225
+ } ?: run {
226
+ Log.d(LOG_TAG, String.format("key %s is null, using default value %s", key, defaultValue))
227
+ // value is already defaultValue
228
+ }
229
+ } catch (e: NoSuchKeyException) {
230
+ // key not found use default value
231
+ Log.d(
232
+ LOG_TAG,
233
+ String.format("No key found for %s, using default value %s", key, defaultValue)
234
+ )
235
+ }
236
+
237
+ return value
238
+ }
239
+ }
@@ -30,8 +30,11 @@ object GeoJSONUtils {
30
30
  "GeoJSONUtils.fromFeature geometry was null for feature: ${feature.toJson()}"
31
31
  )
32
32
  }
33
- val properties = ConvertUtils.toWritableMap(feature.properties())
34
- map.putMap("properties", properties)
33
+
34
+ feature.properties()?.let {
35
+ val properties = ConvertUtils.toWritableMap(it)
36
+ map.putMap("properties", properties)
37
+ }
35
38
  return map
36
39
  }
37
40
 
@@ -733,3 +733,32 @@ class BackgroundPitchAlignment {
733
733
  companion object
734
734
  }
735
735
 
736
+ fun FillExtrusionLayer.fillExtrusionEdgeRadius(
737
+ expression: Expression
738
+ ) {
739
+ // V11 only
740
+ }
741
+
742
+ fun FillExtrusionLayer.fillExtrusionEdgeRadius(
743
+ value: Double
744
+ ) {
745
+ // V11 only
746
+ }
747
+
748
+ fun FillExtrusionLayer.fillExtrusionEmissiveStrength(
749
+ expression: Expression
750
+ ) {
751
+ // V11 only
752
+ }
753
+
754
+ fun FillExtrusionLayer.fillExtrusionEmissiveStrength(
755
+ value: Double
756
+ ) {
757
+ // V11 only
758
+ }
759
+
760
+ fun FillExtrusionLayer.fillExtrusionEmissiveStrengthTransition(
761
+ transition: StyleTransition
762
+ ) {
763
+ // V11 only
764
+ }
@@ -27,7 +27,7 @@ class RNMBXStyleValueTest {
27
27
  fun `getEnumName returns correct enum name`() {
28
28
  Mockito.`when`(mockPayload.getString("value")).thenReturn("test-value")
29
29
 
30
- val styleValue = RNMBXStyleValue(mockConfig)
30
+ val styleValue = RNMBXStyleValue('foo', mockConfig)
31
31
 
32
32
  assertEquals("TEST_VALUE", styleValue.getEnumName())
33
33
  }
@@ -36,7 +36,7 @@ class RNMBXStyleValueTest {
36
36
  fun `getEnumName handles Turkish locale correctly`() {
37
37
  Mockito.`when`(mockPayload.getString("value")).thenReturn("miter")
38
38
 
39
- val styleValue = RNMBXStyleValue(mockConfig)
39
+ val styleValue = RNMBXStyleValue('foo', mockConfig)
40
40
 
41
41
  Locale.setDefault(Locale("tr", "TR"))
42
42
 
@@ -36,7 +36,9 @@ public class RNMBXCustomLocationProvider: UIView, RNMBXMapComponent {
36
36
 
37
37
  @objc
38
38
  override public func didSetProps(_ props: [String]) {
39
- changes.apply(self)
39
+ if customLocationProvider != nil {
40
+ changes.apply(self)
41
+ }
40
42
  }
41
43
 
42
44
  var customLocationProvider: CustomLocationProvider? = nil
@@ -49,6 +51,7 @@ public class RNMBXCustomLocationProvider: UIView, RNMBXMapComponent {
49
51
  self.map = map
50
52
  if let mapView = map.mapView {
51
53
  installCustomeLocationProviderIfNeeded(mapView: mapView)
54
+ changes.apply(self)
52
55
  }
53
56
  }
54
57
 
@@ -12,6 +12,8 @@
12
12
  #import <react/renderer/components/rnmapbox_maps_specs/Props.h>
13
13
  #import <react/renderer/components/rnmapbox_maps_specs/RCTComponentViewHelpers.h>
14
14
 
15
+ #import "RNMBXFabricPropConvert.h"
16
+
15
17
  using namespace facebook::react;
16
18
 
17
19
  @interface RNMBXCustomLocationProviderComponentView () <RCTRNMBXCustomLocationProviderViewProtocol>
@@ -30,7 +32,7 @@ using namespace facebook::react;
30
32
  - (instancetype)initWithFrame:(CGRect)frame
31
33
  {
32
34
  if (self = [super initWithFrame:frame]) {
33
- static const auto defaultProps = std::make_shared<const RNMBXCircleLayerProps>();
35
+ static const auto defaultProps = std::make_shared<const RNMBXCustomLocationProviderProps>();
34
36
  _props = defaultProps;
35
37
  [self prepareView];
36
38
  }
@@ -49,12 +51,20 @@ using namespace facebook::react;
49
51
 
50
52
  + (ComponentDescriptorProvider)componentDescriptorProvider
51
53
  {
52
- return concreteComponentDescriptorProvider<RNMBXCircleLayerComponentDescriptor>();
54
+ return concreteComponentDescriptorProvider<RNMBXCustomLocationProviderComponentDescriptor>();
53
55
  }
54
56
 
55
57
  - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &)oldProps
56
58
  {
59
+ const auto &oldViewProps = static_cast<const RNMBXCustomLocationProviderProps &>(*oldProps);
60
+ const auto &newViewProps = static_cast<const RNMBXCustomLocationProviderProps &>(*props);
61
+
62
+ RNMBX_OPTIONAL_PROP_NumberArray(coordinate)
63
+ RNMBX_OPTIONAL_PROP_NSNumber(heading)
64
+
57
65
  [super updateProps:props oldProps:oldProps];
66
+
67
+ [_view didSetProps:@[]];
58
68
  }
59
69
 
60
70
  - (void)prepareForRecycle
@@ -13,6 +13,7 @@ NSNumber* RNMBXPropConvert_Optional_BOOL_NSNumber(const folly::dynamic &dyn, NSS
13
13
  BOOL RNMBXPropConvert_Optional_BOOL(const folly::dynamic &dyn, NSString* propertyName);
14
14
  NSString* RNMBXPropConvert_Optional_NSString(const folly::dynamic &dyn, NSString* propertyName);
15
15
  NSNumber* RNMBXPropConvert_Optional_NSNumber(const folly::dynamic &dyn, NSString* propertyName);
16
+ NSArray<NSNumber*>* RNMBXPropConvert_Optional_NumberArray(const folly::dynamic &dyn, NSString* propertyName);
16
17
  id RNMBXPropConvert_Optional_ExpressionDouble(const folly::dynamic &dyn, NSString* propertyName);
17
18
  BOOL RNMBXPropConvert_BOOL(const folly::dynamic &dyn, NSString* propertyName);
18
19
  NSDictionary* RNMBXPropConvert_Optional_NSDictionary(const folly::dynamic &dyn, NSString* propertyName);
@@ -27,6 +28,11 @@ NSDictionary* RNMBXPropConvert_Optional_NSDictionary(const folly::dynamic &dyn,
27
28
  _view.viewName = RNMBXPropConvert_Optional_BOOL(newViewProps.name, @#name); \
28
29
  }
29
30
 
31
+ #define RNMBX_REMAP_OPTIONAL_PROP_NSDictionary(name, viewName) \
32
+ if ((!oldProps.get() || oldViewProps.name != newViewProps.name)) { \
33
+ _view.viewName = RNMBXPropConvert_Optional_NSDictionary(newViewProps.name, @#name); \
34
+ }
35
+
30
36
  #define RNMBX_OPTIONAL_PROP_BOOL(name) RNMBX_REMAP_OPTIONAL_PROP_BOOL(name, name)
31
37
 
32
38
  #define RNMBX_OPTIONAL_PROP_NSString(name) \
@@ -34,6 +40,11 @@ NSDictionary* RNMBXPropConvert_Optional_NSDictionary(const folly::dynamic &dyn,
34
40
  _view.name = RNMBXPropConvert_Optional_NSString(newViewProps.name, @#name); \
35
41
  }
36
42
 
43
+ #define RNMBX_OPTIONAL_PROP_NumberArray(name) \
44
+ if ((!oldProps.get() || oldViewProps.name != newViewProps.name) && !newViewProps.name.isNull()) { \
45
+ _view.name = RNMBXPropConvert_Optional_NumberArray(newViewProps.name, @#name); \
46
+ }
47
+
37
48
  #define RNMBX_OPTIONAL_PROP_NSNumber(name) \
38
49
  if ((!oldProps.get() || oldViewProps.name != newViewProps.name) && !newViewProps.name.isNull()) { \
39
50
  _view.name = RNMBXPropConvert_Optional_NSNumber(newViewProps.name, @#name); \
@@ -49,7 +60,4 @@ NSDictionary* RNMBXPropConvert_Optional_NSDictionary(const folly::dynamic &dyn,
49
60
  _view.name = RNMBXPropConvert_BOOL(newViewProps.name, @#name); \
50
61
  }
51
62
 
52
- #define RNMBX_OPTIONAL_PROP_NSDictionary(name) \
53
- if ((!oldProps.get() || oldViewProps.name != newViewProps.name)) { \
54
- _view.name = RNMBXPropConvert_Optional_NSDictionary(newViewProps.name, @#name); \
55
- }
63
+ #define RNMBX_OPTIONAL_PROP_NSDictionary(name) RNMBX_REMAP_OPTIONAL_PROP_NSDictionary(name, name)
@@ -153,4 +153,8 @@ NSDictionary* RNMBXPropConvert_Optional_NSDictionary(const folly::dynamic &dyn,
153
153
  return RNMBXPropConvert_ID(dyn);
154
154
  }
155
155
 
156
+ NSArray<NSNumber*> * RNMBXPropConvert_Optional_NumberArray(const folly::dynamic &dyn, NSString* propertyName) {
157
+ return RNMBXPropConvert_ID(dyn);
158
+ }
159
+
156
160
  #endif
@@ -190,6 +190,8 @@ using namespace facebook::react;
190
190
  RNMBX_REMAP_OPTIONAL_PROP_BOOL(rotateEnabled, reactRotateEnabled)
191
191
 
192
192
  RNMBX_REMAP_OPTIONAL_PROP_BOOL(pitchEnabled, reactPitchEnabled)
193
+
194
+ RNMBX_REMAP_OPTIONAL_PROP_NSDictionary(gestureSettings, reactGestureSettings)
193
195
 
194
196
  id preferredFramesPerSecond = RNMBXConvertFollyDynamicToId(newViewProps.preferredFramesPerSecond);
195
197
  if (preferredFramesPerSecond != nil) {
@@ -11,6 +11,8 @@
11
11
  #import <react/renderer/components/rnmapbox_maps_specs/Props.h>
12
12
  #import <react/renderer/components/rnmapbox_maps_specs/RCTComponentViewHelpers.h>
13
13
 
14
+ #import "RNMBXFabricPropConvert.h"
15
+
14
16
  using namespace facebook::react;
15
17
 
16
18
  @interface RNMBXPointAnnotationComponentView () <RCTRNMBXPointAnnotationViewProtocol>
@@ -40,9 +42,9 @@ using namespace facebook::react;
40
42
  - (void)prepareView
41
43
  {
42
44
  _view = [[RNMBXPointAnnotation alloc] init];
43
-
45
+
44
46
  self.contentView = _view;
45
-
47
+
46
48
  // capture weak self reference to prevent retain cycle
47
49
  __weak __typeof__(self) weakSelf = self;
48
50
 
@@ -122,24 +124,14 @@ using namespace facebook::react;
122
124
 
123
125
  - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &)oldProps
124
126
  {
125
- const auto &newProps = static_cast<const RNMBXPointAnnotationProps &>(*props);
126
- id coordinate = RNMBXConvertFollyDynamicToId(newProps.coordinate);
127
- if (coordinate != nil) {
128
- _view.coordinate = coordinate;
129
- }
130
- id draggable = RNMBXConvertFollyDynamicToId(newProps.draggable);
131
- if (draggable != nil) {
132
- _view.draggable = draggable;
133
- }
134
- id idx = RNMBXConvertFollyDynamicToId(newProps.id);
135
- if (idx != nil) {
136
- _view.id = idx;
137
- }
138
- id anchor = RNMBXConvertFollyDynamicToId(newProps.anchor);
139
- if (anchor != nil) {
140
- _view.anchor = anchor;
141
- }
142
-
127
+ const auto &oldViewProps = static_cast<const RNMBXPointAnnotationProps &>(*oldProps);
128
+ const auto &newViewProps = static_cast<const RNMBXPointAnnotationProps &>(*props);
129
+
130
+ RNMBX_OPTIONAL_PROP_NSString(coordinate)
131
+ RNMBX_OPTIONAL_PROP_BOOL(draggable)
132
+ RNMBX_OPTIONAL_PROP_NSString(id)
133
+ RNMBX_OPTIONAL_PROP_NSDictionary(anchor)
134
+
143
135
  [super updateProps:props oldProps:oldProps];
144
136
  }
145
137
 
@@ -231,7 +231,7 @@ class MapView extends NativeBridgeComponent(React.PureComponent, NativeMapViewMo
231
231
  * @example
232
232
  * this._map.queryRenderedFeaturesInRect([30, 40, 20, 10], ['==', 'type', 'Point'], ['id1', 'id2'])
233
233
  *
234
- * @param {Array<Number>} bbox - A rectangle expressed in the map view’s coordinate system. For v10, this can be an empty array to query the visible map area.
234
+ * @param {Array<Number>} bbox - A rectangle expressed in the map view’s coordinate system, density independent pixels and not map coordinates. This can be an empty array to query the visible map area.
235
235
  * @param {Array=} filter - A set of strings that correspond to the names of layers defined in the current style. Only the features contained in these layers are included in the returned array.
236
236
  * @param {Array=} layerIDs - A array of layer id's to filter the features by
237
237
  * @return {FeatureCollection}
@@ -460,7 +460,7 @@ declare class MapView extends MapView_base {
460
460
  * @example
461
461
  * this._map.queryRenderedFeaturesInRect([30, 40, 20, 10], ['==', 'type', 'Point'], ['id1', 'id2'])
462
462
  *
463
- * @param {Array<Number>} bbox - A rectangle expressed in the map view’s coordinate system. For v10, this can be an empty array to query the visible map area.
463
+ * @param {Array<Number>} bbox - A rectangle expressed in the map view’s coordinate system, density independent pixels and not map coordinates. This can be an empty array to query the visible map area.
464
464
  * @param {Array=} filter - A set of strings that correspond to the names of layers defined in the current style. Only the features contained in these layers are included in the returned array.
465
465
  * @param {Array=} layerIDs - A array of layer id's to filter the features by
466
466
  * @return {FeatureCollection}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rnmapbox/maps",
3
- "version": "10.2.4",
3
+ "version": "10.2.6",
4
4
  "description": "Community-supported, open-source React Native library for building maps using Mapbox native maps SDK for iOS and Android",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.native.d.ts",
@@ -755,7 +755,7 @@ class MapView extends NativeBridgeComponent(
755
755
  * @example
756
756
  * this._map.queryRenderedFeaturesInRect([30, 40, 20, 10], ['==', 'type', 'Point'], ['id1', 'id2'])
757
757
  *
758
- * @param {Array<Number>} bbox - A rectangle expressed in the map view’s coordinate system. For v10, this can be an empty array to query the visible map area.
758
+ * @param {Array<Number>} bbox - A rectangle expressed in the map view’s coordinate system, density independent pixels and not map coordinates. This can be an empty array to query the visible map area.
759
759
  * @param {Array=} filter - A set of strings that correspond to the names of layers defined in the current style. Only the features contained in these layers are included in the returned array.
760
760
  * @param {Array=} layerIDs - A array of layer id's to filter the features by
761
761
  * @return {FeatureCollection}
@@ -1,253 +0,0 @@
1
- package com.rnmapbox.rnmbx.utils;
2
-
3
- import android.graphics.PointF;
4
- import android.graphics.RectF;
5
- import android.util.Log;
6
-
7
- import com.facebook.react.bridge.Arguments;
8
- import com.facebook.react.bridge.NoSuchKeyException;
9
- import com.facebook.react.bridge.ReadableArray;
10
- import com.facebook.react.bridge.ReadableMap;
11
- import com.facebook.react.bridge.ReadableMapKeySetIterator;
12
- import com.facebook.react.bridge.ReadableType;
13
- import com.facebook.react.bridge.WritableArray;
14
- import com.facebook.react.bridge.WritableMap;
15
- import com.google.gson.JsonArray;
16
- import com.google.gson.JsonElement;
17
- import com.google.gson.JsonObject;
18
- import com.google.gson.JsonPrimitive;
19
-
20
- import java.text.NumberFormat;
21
- import java.text.ParseException;
22
- import java.util.ArrayList;
23
- import java.util.List;
24
- import java.util.Map;
25
-
26
- public class ConvertUtils {
27
- public static final String LOG_TAG = "ConvertUtils";
28
-
29
- public static JsonObject toJsonObject(ReadableMap map) {
30
- if (map == null) return null;
31
- JsonObject result = new JsonObject();
32
- ReadableMapKeySetIterator it = map.keySetIterator();
33
-
34
- while (it.hasNextKey()) {
35
- String key = it.nextKey();
36
- switch (map.getType(key)) {
37
- case Map:
38
- result.add(key, toJsonObject(map.getMap(key)));
39
- break;
40
- case Array:
41
- result.add(key, toJsonArray(map.getArray(key)));
42
- break;
43
- case Null:
44
- result.add(key, null);
45
- break;
46
- case Number:
47
- result.addProperty(key, map.getDouble(key));
48
- break;
49
- case String:
50
- result.addProperty(key, map.getString(key));
51
- break;
52
- case Boolean:
53
- result.addProperty(key, map.getBoolean(key));
54
- break;
55
- }
56
- }
57
- return result;
58
- }
59
-
60
- public static JsonArray toJsonArray(ReadableArray array) {
61
- if (array == null) return null;
62
- JsonArray result = new JsonArray(array.size());
63
- for (int i = 0; i < array.size(); i++) {
64
- switch (array.getType(i)) {
65
- case Map:
66
- result.add(toJsonObject(array.getMap(i)));
67
- break;
68
- case Array:
69
- result.add(toJsonArray(array.getArray(i)));
70
- break;
71
- case Null:
72
- result.add((JsonElement)null);
73
- break;
74
- case Number:
75
- result.add(array.getDouble(i));
76
- break;
77
- case String:
78
- result.add(array.getString(i));
79
- break;
80
- case Boolean:
81
- result.add(array.getBoolean(i));
82
- break;
83
- }
84
- }
85
- return result;
86
- }
87
-
88
- public static JsonElement typedToJsonElement(ReadableMap map) {
89
- if (map == null) return null;
90
-
91
- String type = map.getString("type");
92
-
93
- if (type.equals(ExpressionParser.TYPE_MAP)) {
94
- JsonObject result = new JsonObject();
95
-
96
- ReadableArray keyValues = map.getArray("value");
97
- for (int i = 0; i < keyValues.size(); i++) {
98
- ReadableArray keyValue = keyValues.getArray(i);
99
- String key = keyValue.getMap(0).getString("value");
100
-
101
- result.add(key, typedToJsonElement(keyValue.getMap(1)));
102
- }
103
- return result;
104
- }
105
- else if (type.equals(ExpressionParser.TYPE_ARRAY)) {
106
- ReadableArray arrayValue = map.getArray("value");
107
- JsonArray result = new JsonArray(arrayValue.size());
108
- for (int i = 0; i < arrayValue.size(); i++) {
109
- result.add(typedToJsonElement(arrayValue.getMap(i)));
110
- }
111
- return result;
112
- }
113
- else if (type.equals(ExpressionParser.TYPE_BOOL)) {
114
- return new JsonPrimitive(map.getBoolean("value"));
115
- }
116
- else if (type.equals(ExpressionParser.TYPE_NUMBER)) {
117
- return new JsonPrimitive(map.getDouble("value"));
118
- }
119
- else if (type.equals(ExpressionParser.TYPE_STRING)) {
120
- return new JsonPrimitive(map.getString("value"));
121
- }
122
- else {
123
- throw new RuntimeException(String.format("Unrecognized type {}", map.getString("type")));
124
- }
125
- }
126
-
127
- public static WritableArray toWritableArray(JsonArray array) {
128
- WritableArray writableArray = Arguments.createArray();
129
-
130
- for (int i = 0; i < array.size(); i++) {
131
- JsonElement element = array.get(i);
132
-
133
- if (element.isJsonArray()) {
134
- writableArray.pushArray(toWritableArray(element.getAsJsonArray()));
135
- } else if (element.isJsonObject()) {
136
- writableArray.pushMap(toWritableMap(element.getAsJsonObject()));
137
- } else if (element.isJsonPrimitive()) {
138
- JsonPrimitive primitive = element.getAsJsonPrimitive();
139
-
140
- if (primitive.isBoolean()) {
141
- writableArray.pushBoolean(primitive.getAsBoolean());
142
- } else if (primitive.isNumber()) {
143
- writableArray.pushDouble(primitive.getAsDouble());
144
- } else {
145
- writableArray.pushString(primitive.getAsString());
146
- }
147
- }
148
- }
149
-
150
- return writableArray;
151
- }
152
-
153
- public static WritableMap toWritableMap(JsonObject object) {
154
- WritableMap map = Arguments.createMap();
155
-
156
- for (Map.Entry<String, JsonElement> entry : object.entrySet()) {
157
- String propName = entry.getKey();
158
- JsonElement jsonElement = entry.getValue();
159
-
160
- if (jsonElement.isJsonPrimitive()) {
161
- JsonPrimitive primitive = jsonElement.getAsJsonPrimitive();
162
-
163
- if (primitive.isBoolean()) {
164
- map.putBoolean(propName, primitive.getAsBoolean());
165
- } else if (primitive.isNumber()) {
166
- map.putDouble(propName, primitive.getAsDouble());
167
- } else {
168
- map.putString(propName, primitive.getAsString());
169
- }
170
- } else if (jsonElement.isJsonArray()) {
171
- map.putArray(propName, toWritableArray(jsonElement.getAsJsonArray()));
172
- } else if (jsonElement.isJsonObject()) {
173
- map.putMap(propName, toWritableMap(jsonElement.getAsJsonObject()));
174
- }
175
- }
176
-
177
- return map;
178
- }
179
-
180
- public static Object getObjectFromString(String str) {
181
- NumberFormat numberFormat = NumberFormat.getNumberInstance();
182
-
183
- try {
184
- return numberFormat.parse(str);
185
- } catch (ParseException e) {
186
- // ignore we're just figuring out what type this is
187
- }
188
-
189
- return str;
190
- }
191
-
192
- public static List<String> toStringList(ReadableArray array) {
193
- List<String> list = new ArrayList<>();
194
-
195
- if (array == null) {
196
- return list;
197
- }
198
-
199
- for (int i = 0; i < array.size(); i++) {
200
- list.add(array.getString(i));
201
- }
202
-
203
- return list;
204
- }
205
-
206
- public static PointF toPointF(ReadableArray array) {
207
- PointF pointF = new PointF();
208
-
209
- if (array == null) {
210
- return pointF;
211
- }
212
-
213
- pointF.set((float)array.getDouble(0), (float)array.getDouble(1));
214
- return pointF;
215
- }
216
-
217
- public static RectF toRectF(ReadableArray array) {
218
- RectF rectF = new RectF();
219
-
220
- if (array == null || array.size() == 0) {
221
- return rectF;
222
- }
223
-
224
- rectF.set((float)array.getDouble(3), (float)array.getDouble(0), (float)array.getDouble(1), (float)array.getDouble(2));
225
- return rectF;
226
- }
227
-
228
- public static double getDouble(String key, ReadableMap map, double defaultValue) {
229
- double value = defaultValue;
230
-
231
- try {
232
- value = map.getDouble(key);
233
- } catch (NoSuchKeyException e) {
234
- // key not found use default value
235
- Log.d(LOG_TAG, String.format("No key found for %s, using default value %f", key, defaultValue));
236
- }
237
-
238
- return value;
239
- }
240
-
241
- public static String getString(String key, ReadableMap map, String defaultValue) {
242
- String value = defaultValue;
243
-
244
- try {
245
- value = map.getString(key);
246
- } catch (NoSuchKeyException e) {
247
- // key not found use default value
248
- Log.d(LOG_TAG, String.format("No key found for %s, using default value %s", key, defaultValue));
249
- }
250
-
251
- return value;
252
- }
253
- }
@@ -1,35 +0,0 @@
1
- package com.rnmapbox.rnmbx.v11compat.layers;
2
-
3
- import com.mapbox.maps.extension.style.expressions.generated.Expression
4
- import com.mapbox.maps.extension.style.layers.generated.FillExtrusionLayer
5
- import com.mapbox.maps.extension.style.types.StyleTransition
6
-
7
- fun FillExtrusionLayer.fillExtrusionEdgeRadius(
8
- expression: Expression
9
- ) {
10
- // V11 only
11
- }
12
-
13
- fun FillExtrusionLayer.fillExtrusionEdgeRadius(
14
- value: Double
15
- ) {
16
- // V11 only
17
- }
18
-
19
- fun FillExtrusionLayer.fillExtrusionEmissiveStrength(
20
- expression: Expression
21
- ) {
22
- // V11 only
23
- }
24
-
25
- fun FillExtrusionLayer.fillExtrusionEmissiveStrength(
26
- value: Double
27
- ) {
28
- // V11 only
29
- }
30
-
31
- fun FillExtrusionLayer.fillExtrusionEmissiveStrengthTransition(
32
- transition: StyleTransition
33
- ) {
34
- // V11 only
35
- }
@@ -1 +0,0 @@
1
- package com.rnmapbox.rnmbx.v11compat.layers;