Skip to content

Commit 512c508

Browse files
authored
chore: upgrade Mapbox SDK to 11.18.2 and update style spec (#4161)
1 parent ea88768 commit 512c508

File tree

12 files changed

+368
-88
lines changed

12 files changed

+368
-88
lines changed

android/src/main/java/com/rnmapbox/rnmbx/components/styles/RNMBXStyleFactory.kt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,8 @@ object RNMBXStyleFactory {
795795
val styleValue = style.getStyleValueForKey(styleKey)
796796

797797
when (styleKey) {
798+
"modelAllowDensityReduction" ->
799+
setModelAllowDensityReduction(layer, styleValue)
798800
"visibility" ->
799801
setVisibility(layer, styleValue)
800802
"modelId" ->
@@ -847,6 +849,8 @@ object RNMBXStyleFactory {
847849
setModelHeightBasedEmissiveStrengthMultiplierTransition(layer, styleValue)
848850
"modelCutoffFadeRange" ->
849851
setModelCutoffFadeRange(layer, styleValue)
852+
"modelElevationReference" ->
853+
setModelElevationReference(layer, styleValue)
850854
}
851855
} catch (e: MapboxStyleException) {
852856
Logger.e(LOG_TAG, "Failed to update: $styleKey ${e.message}")
@@ -4673,6 +4677,24 @@ object RNMBXStyleFactory {
46734677
}
46744678
}
46754679

4680+
fun setModelAllowDensityReduction(layer: ModelLayer, styleValue: RNMBXStyleValue ) {
4681+
if (styleValue.isExpression()) {
4682+
val expression = styleValue.getExpression()
4683+
if (expression != null) {
4684+
layer.modelAllowDensityReduction(expression)
4685+
} else {
4686+
Logger.e("RNMBXModel", "Expression for modelAllowDensityReduction is null")
4687+
}
4688+
} else {
4689+
val value = styleValue.getBoolean(VALUE_KEY)
4690+
if (value != null) {
4691+
layer.modelAllowDensityReduction(value)
4692+
} else {
4693+
Logger.e("RNMBXModel", "value for modelAllowDensityReduction is null")
4694+
}
4695+
}
4696+
}
4697+
46764698
fun setVisibility(layer: ModelLayer, styleValue: RNMBXStyleValue ) {
46774699
layer.visibility(Visibility.valueOf(styleValue.getEnumName()));
46784700
}
@@ -5022,6 +5044,19 @@ object RNMBXStyleFactory {
50225044
}
50235045
}
50245046

5047+
fun setModelElevationReference(layer: ModelLayer, styleValue: RNMBXStyleValue ) {
5048+
if (styleValue.isExpression()) {
5049+
val expression = styleValue.getExpression()
5050+
if (expression != null) {
5051+
layer.modelElevationReference(expression)
5052+
} else {
5053+
Logger.e("RNMBXModel", "Expression for modelElevationReference is null")
5054+
}
5055+
} else {
5056+
layer.modelElevationReference(ModelElevationReference.valueOf(styleValue.getEnumName()))
5057+
}
5058+
}
5059+
50255060
fun setVisibility(layer: BackgroundLayer, styleValue: RNMBXStyleValue ) {
50265061
layer.visibility(Visibility.valueOf(styleValue.getEnumName()));
50275062
}

docs/BackgroundLayer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ The color with which the background will be drawn.
201201

202202
#### Expression
203203

204-
Parameters: `zoom`
204+
Parameters: `zoom, measure-light`
205205
___
206206

207207
### backgroundColorTransition

docs/LineLayer.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -282,14 +282,7 @@ Name: `lineZOffset`
282282
Mapbox spec: [line-z-offset](https://docs.mapbox.com/style-spec/reference/layers/#layout-line-line-z-offset)
283283

284284
#### Description
285-
Vertical offset from ground, in meters. Defaults to 0. This is an experimental property with some known issues:
286-
* Not supported for globe projection at the moment
287-
* Elevated line discontinuity is possible on tile borders with terrain enabled
288-
* Rendering artifacts can happen near line joins and line caps depending on the line styling
289-
* Rendering artifacts relating to `lineOpacity` and `lineBlur`
290-
* Elevated line visibility is determined by layer order
291-
* ZFighting issues can happen with intersecting elevated lines
292-
* Elevated lines don't cast shadows
285+
Vertical offset from ground, in meters. Not supported for globe projection at the moment.
293286

294287
#### Type
295288
`number`

docs/ModelLayer.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ Customizable style attributes
138138

139139
* <a href="#visibility">visibility</a><br/>
140140
* <a href="#modelid">modelId</a><br/>
141+
* <a href="#modelallowdensityreduction">modelAllowDensityReduction</a><br/>
141142
* <a href="#modelopacity">modelOpacity</a><br/>
142143
* <a href="#modelrotation">modelRotation</a><br/>
143144
* <a href="#modelscale">modelScale</a><br/>
@@ -152,6 +153,7 @@ Customizable style attributes
152153
* <a href="#modelroughness">modelRoughness</a><br/>
153154
* <a href="#modelheightbasedemissivestrengthmultiplier">modelHeightBasedEmissiveStrengthMultiplier</a><br/>
154155
* <a href="#modelcutofffaderange">modelCutoffFadeRange</a><br/>
156+
* <a href="#modelelevationreference">modelElevationReference</a><br/>
155157

156158
___
157159

@@ -197,6 +199,23 @@ Model to render. It can be either a string referencing an element to the models
197199

198200
Parameters: `zoom, feature`
199201

202+
___
203+
204+
### modelAllowDensityReduction
205+
Name: `modelAllowDensityReduction`
206+
207+
Mapbox spec: [model-allow-density-reduction](https://docs.mapbox.com/style-spec/reference/layers/#layout-model-model-allow-density-reduction)
208+
209+
#### Description
210+
If true, the models will be reduced in density based on the zoom level. This is useful for large datasets that may be slow to render.
211+
212+
#### Type
213+
`boolean`
214+
#### Default Value
215+
`true`
216+
217+
218+
200219
___
201220

202221
### modelOpacity
@@ -704,3 +723,28 @@ This parameter defines the range for the fadeOut effect before an automatic cont
704723

705724
Parameters: ``
706725

726+
___
727+
728+
### modelElevationReference
729+
Name: `modelElevationReference`
730+
731+
Mapbox spec: [model-elevation-reference](https://docs.mapbox.com/style-spec/reference/layers/#paint-model-model-elevation-reference)
732+
733+
#### Description
734+
Selects the base of the model. Some modes might require precomputed elevation data in the tileset. When using vector tiled source as the model layer source and hdRoadMarkup elevation reference, this property acts as layout property and elevation is evaluated only in tile loading time.
735+
736+
#### Type
737+
`enum`
738+
#### Default Value
739+
`ground`
740+
741+
#### Supported Values
742+
**sea** - Elevated rendering is enabled. Use this mode to elevate models relative to the sea level.<br />
743+
**ground** - Elevated rendering is enabled. Use this mode to elevate models relative to the ground's height below them.<br />
744+
**hd-road-markup** - Elevated rendering is enabled. Use this mode to describe additive and stackable features that should exist only on top of road polygons.<br />
745+
746+
747+
#### Expression
748+
749+
Parameters: ``
750+

docs/RasterLayer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ Name: `rasterElevation`
665665
Mapbox spec: [raster-elevation](https://docs.mapbox.com/style-spec/reference/layers/#paint-raster-raster-elevation)
666666

667667
#### Description
668-
Specifies an uniform elevation from the ground, in meters.
668+
Defines an uniform elevation from the base specified in rasterElevationReference, in meters.
669669

670670
#### Type
671671
`number`

docs/docs.json

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,8 @@
514514
"expression": {
515515
"interpolated": true,
516516
"parameters": [
517-
"zoom"
517+
"zoom",
518+
"measure-light"
518519
]
519520
},
520521
"transition": true,
@@ -3842,7 +3843,7 @@
38423843
"type": "number",
38433844
"values": [],
38443845
"default": 0,
3845-
"description": "Vertical offset from ground, in meters. Defaults to 0. This is an experimental property with some known issues:\n * Not supported for globe projection at the moment \n * Elevated line discontinuity is possible on tile borders with terrain enabled \n * Rendering artifacts can happen near line joins and line caps depending on the line styling \n * Rendering artifacts relating to `lineOpacity` and `lineBlur` \n * Elevated line visibility is determined by layer order \n * ZFighting issues can happen with intersecting elevated lines \n * Elevated lines don't cast shadows",
3846+
"description": "Vertical offset from ground, in meters. Not supported for globe projection at the moment.",
38463847
"requires": [
38473848
"lineElevationReference"
38483849
],
@@ -5822,6 +5823,22 @@
58225823
"namespace": "layout"
58235824
}
58245825
},
5826+
{
5827+
"name": "modelAllowDensityReduction",
5828+
"type": "boolean",
5829+
"values": [],
5830+
"default": true,
5831+
"description": "If true, the models will be reduced in density based on the zoom level. This is useful for large datasets that may be slow to render.",
5832+
"requires": [],
5833+
"disabledBy": [],
5834+
"allowedFunctionTypes": [],
5835+
"transition": false,
5836+
"mbx": {
5837+
"fullName": "layout-model-model-allow-density-reduction",
5838+
"name": "model-allow-density-reduction",
5839+
"namespace": "layout"
5840+
}
5841+
},
58255842
{
58265843
"name": "modelOpacity",
58275844
"type": "number",
@@ -6166,6 +6183,38 @@
61666183
"name": "model-cutoff-fade-range",
61676184
"namespace": "paint"
61686185
}
6186+
},
6187+
{
6188+
"name": "modelElevationReference",
6189+
"type": "enum",
6190+
"values": [
6191+
{
6192+
"value": "sea",
6193+
"doc": "Elevated rendering is enabled. Use this mode to elevate models relative to the sea level."
6194+
},
6195+
{
6196+
"value": "ground",
6197+
"doc": "Elevated rendering is enabled. Use this mode to elevate models relative to the ground's height below them."
6198+
},
6199+
{
6200+
"value": "hd-road-markup",
6201+
"doc": "Elevated rendering is enabled. Use this mode to describe additive and stackable features that should exist only on top of road polygons."
6202+
}
6203+
],
6204+
"default": "ground",
6205+
"description": "Selects the base of the model. Some modes might require precomputed elevation data in the tileset. When using vector tiled source as the model layer source and hdRoadMarkup elevation reference, this property acts as layout property and elevation is evaluated only in tile loading time.",
6206+
"requires": [],
6207+
"disabledBy": [],
6208+
"allowedFunctionTypes": [],
6209+
"expression": {
6210+
"interpolated": false
6211+
},
6212+
"transition": false,
6213+
"mbx": {
6214+
"fullName": "paint-model-model-elevation-reference",
6215+
"name": "model-elevation-reference",
6216+
"namespace": "paint"
6217+
}
61696218
}
61706219
]
61716220
},
@@ -6931,7 +6980,7 @@
69316980
"values": [],
69326981
"minimum": 0,
69336982
"default": 0,
6934-
"description": "Specifies an uniform elevation from the ground, in meters.",
6983+
"description": "Defines an uniform elevation from the base specified in rasterElevationReference, in meters.",
69356984
"requires": [],
69366985
"disabledBy": [],
69376986
"allowedFunctionTypes": [],

ios/RNMBX/RNMBXStyle.swift

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,9 @@ func modelLayer(layer: inout ModelLayer, reactStyle:Dictionary<String, Any>, old
798798

799799
let styleValue = RNMBXStyleValue.make(reactStyle[prop])
800800

801-
if (prop == "visibility") {
801+
if (prop == "modelAllowDensityReduction") {
802+
self.setModelAllowDensityReduction(&layer, styleValue:styleValue);
803+
} else if (prop == "visibility") {
802804
self.setModelStyleLayerVisibility(&layer, styleValue:styleValue);
803805
} else if (prop == "modelId") {
804806
self.setModelId(&layer, styleValue:styleValue);
@@ -850,6 +852,8 @@ func modelLayer(layer: inout ModelLayer, reactStyle:Dictionary<String, Any>, old
850852
self.setModelHeightBasedEmissiveStrengthMultiplierTransition(&layer, styleValue:styleValue);
851853
} else if (prop == "modelCutoffFadeRange") {
852854
self.setModelCutoffFadeRange(&layer, styleValue:styleValue);
855+
} else if (prop == "modelElevationReference") {
856+
self.setModelElevationReference(&layer, styleValue:styleValue);
853857
} else {
854858
Logger.log(level:.error, message: "Unexpected property \(prop) for layer: model")
855859
}
@@ -3057,6 +3061,15 @@ func setHillshadeAccentColorTransition(_ layer: inout HillshadeLayer, styleValue
30573061

30583062

30593063

3064+
func setModelAllowDensityReduction(_ layer: inout ModelLayer, styleValue: RNMBXStyleValue)
3065+
{
3066+
3067+
3068+
layer.modelAllowDensityReduction = styleValue.mglStyleValueBoolean();
3069+
3070+
3071+
}
3072+
30603073
func setModelStyleLayerVisibility(_ layer: inout ModelLayer, styleValue: RNMBXStyleValue)
30613074
{
30623075
layer.visibility = styleValue.isVisible();
@@ -3247,6 +3260,15 @@ func setModelCutoffFadeRange(_ layer: inout ModelLayer, styleValue: RNMBXStyleVa
32473260

32483261
}
32493262

3263+
func setModelElevationReference(_ layer: inout ModelLayer, styleValue: RNMBXStyleValue)
3264+
{
3265+
3266+
3267+
layer.modelElevationReference = styleValue.mglStyleValueEnum();
3268+
3269+
3270+
}
3271+
32503272

32513273

32523274
func setBackgroundStyleLayerVisibility(_ layer: inout BackgroundLayer, styleValue: RNMBXStyleValue)

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@
7474
},
7575
"homepage": "https://github.com/rnmapbox/maps#readme",
7676
"mapbox": {
77-
"ios": "~> 11.16.2",
78-
"android": "11.16.2"
77+
"ios": "~> 11.18.2",
78+
"android": "11.18.2"
7979
},
8080
"publishConfig": {
8181
"registry": "https://registry.npmjs.org/",

plugin/install.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ After installing this package, add the [config plugin](https://docs.expo.io/guid
2020
[
2121
"@rnmapbox/maps",
2222
{
23-
"RNMapboxMapsVersion": "11.13.4"
23+
"RNMapboxMapsVersion": "11.18.2"
2424
}
2525
]
2626
]
@@ -58,7 +58,7 @@ It's possible to overwrite the native SDK version with `RNMapboxMapsVersion`:
5858
[
5959
"@rnmapbox/maps",
6060
{
61-
"RNMapboxMapsVersion": "11.16.0"
61+
"RNMapboxMapsVersion": "11.18.2"
6262
}
6363
]
6464
]

0 commit comments

Comments
 (0)