Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.mapbox.maps.extension.style.layers.generated.SymbolLayer;
import com.mapbox.maps.extension.style.layers.generated.HeatmapLayer;
import com.mapbox.maps.extension.style.layers.generated.HillshadeLayer;
import com.mapbox.maps.extension.style.atmosphere.generated.Atmosphere;
// import com.mapbox.maps.extension.style.layers.properties.generated.Visibility;
import com.mapbox.maps.extension.style.layers.properties.generated.*;
import com.mapbox.maps.extension.style.types.StyleTransition;
Expand Down Expand Up @@ -184,6 +185,9 @@ public void onAllImagesLoaded() {
case "lineGradient":
RCTMGLStyleFactory.setLineGradient(layer, styleValue);
break;
case "lineTrimOffset":
RCTMGLStyleFactory.setLineTrimOffset(layer, styleValue);
break;
}
}
}
Expand Down Expand Up @@ -820,6 +824,38 @@ public static void setLightLayerStyle(final Light layer, RCTMGLStyle style) {
}
}
}
public static void setAtmosphereLayerStyle(final Atmosphere layer, RCTMGLStyle style) {
List<String> styleKeys = style.getAllStyleKeys();

if (styleKeys.size() == 0) {
return;
}

for (String styleKey : styleKeys) {
final RCTMGLStyleValue styleValue = style.getStyleValueForKey(styleKey);

switch (styleKey) {
case "range":
RCTMGLStyleFactory.setRange(layer, styleValue);
break;
case "color":
RCTMGLStyleFactory.setColor(layer, styleValue);
break;
case "highColor":
RCTMGLStyleFactory.setHighColor(layer, styleValue);
break;
case "spaceColor":
RCTMGLStyleFactory.setSpaceColor(layer, styleValue);
break;
case "horizonBlend":
RCTMGLStyleFactory.setHorizonBlend(layer, styleValue);
break;
case "starIntensity":
RCTMGLStyleFactory.setStarIntensity(layer, styleValue);
break;
}
}
}

public static void setFillSortKey(FillLayer layer, RCTMGLStyleValue styleValue) {
if (styleValue.isExpression()) {
Expand Down Expand Up @@ -1141,6 +1177,14 @@ public static void setLineGradient(LineLayer layer, RCTMGLStyleValue styleValue)
}
}

public static void setLineTrimOffset(LineLayer layer, RCTMGLStyleValue styleValue) {
if (styleValue.isExpression()) {
layer.lineTrimOffset(styleValue.getExpression());
} else {
layer.lineTrimOffset(styleValue.getFloatArray(VALUE_KEY));
}
}

public static void setSymbolPlacement(SymbolLayer layer, RCTMGLStyleValue styleValue) {
if (styleValue.isExpression()) {
layer.symbolPlacement(styleValue.getExpression());
Expand Down Expand Up @@ -2433,4 +2477,52 @@ public static void setIntensityTransition(Light layer, RCTMGLStyleValue styleVal
}
}

public static void setRange(Atmosphere layer, RCTMGLStyleValue styleValue) {
if (styleValue.isExpression()) {
layer.range(styleValue.getExpression());
} else {
layer.range(styleValue.getFloatArray(VALUE_KEY));
}
}

public static void setColor(Atmosphere layer, RCTMGLStyleValue styleValue) {
if (styleValue.isExpression()) {
layer.color(styleValue.getExpression());
} else {
layer.color(styleValue.getInt(VALUE_KEY));
}
}

public static void setHighColor(Atmosphere layer, RCTMGLStyleValue styleValue) {
if (styleValue.isExpression()) {
layer.highColor(styleValue.getExpression());
} else {
layer.highColor(styleValue.getInt(VALUE_KEY));
}
}

public static void setSpaceColor(Atmosphere layer, RCTMGLStyleValue styleValue) {
if (styleValue.isExpression()) {
layer.spaceColor(styleValue.getExpression());
} else {
layer.spaceColor(styleValue.getInt(VALUE_KEY));
}
}

public static void setHorizonBlend(Atmosphere layer, RCTMGLStyleValue styleValue) {
if (styleValue.isExpression()) {
layer.horizonBlend(styleValue.getExpression());
} else {
layer.horizonBlend(styleValue.getFloat(VALUE_KEY));
}
}

public static void setStarIntensity(Atmosphere layer, RCTMGLStyleValue styleValue) {
if (styleValue.isExpression()) {
layer.starIntensity(styleValue.getExpression());
} else {
layer.starIntensity(styleValue.getFloat(VALUE_KEY));
}
}

}
22 changes: 22 additions & 0 deletions docs/LineLayer.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
* <a href="#linedasharray">lineDasharray</a><br/>
* <a href="#linepattern">linePattern</a><br/>
* <a href="#linegradient">lineGradient</a><br/>
* <a href="#linetrimoffset">lineTrimOffset</a><br/>

___

Expand Down Expand Up @@ -582,3 +583,24 @@ Defines a gradient with which to color a line feature. Can only be used with Geo

Parameters: `line-progress`

___

#### lineTrimOffset
Name: `lineTrimOffset`

#### Description
The line part between [trimStart, trimEnd] will be marked as transparent to make a route vanishing effect. The line trimOff offset is based on the whole line range [0.0, 1.0].

#### Type
`array<number>`
#### Default Value
`[0,0]`

#### Minimum
`0,0`


#### Maximum
`1,1`


2 changes: 1 addition & 1 deletion docs/SymbolLayer.md
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ ___
Name: `textField`

#### Description
Value to use for a text label. If a plain `string` is provided, it will be treated as a `formatted` with default/inherited formatting options.
Value to use for a text label. If a plain `string` is provided, it will be treated as a `formatted` with default/inherited formatting options. SDF images are not supported in formatted text and will be ignored.

#### Type
`formatted`
Expand Down
2 changes: 1 addition & 1 deletion docs/Terrain.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!-- This file was autogenerated from Terrain.js do not modify -->
## <MapboxGL.Terrain />
### Terrain renders a terran
### A global modifier that elevates layers and markers based on a DEM data source.

### props
| Prop | Type | Default | Required | Description |
Expand Down
26 changes: 24 additions & 2 deletions docs/docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -2555,6 +2555,28 @@
]
},
"transition": false
},
{
"name": "lineTrimOffset",
"type": "array<number>",
"values": [],
"minimum": [
0,
0
],
"maximum": [
1,
1
],
"default": [
0,
0
],
"description": "The line part between [trimStart, trimEnd] will be marked as transparent to make a route vanishing effect. The line trimOff offset is based on the whole line range [0.0, 1.0].",
"requires": [],
"disabledBy": [],
"allowedFunctionTypes": [],
"transition": false
}
]
},
Expand Down Expand Up @@ -5020,7 +5042,7 @@
"type": "formatted",
"values": [],
"default": "",
"description": "Value to use for a text label. If a plain `string` is provided, it will be treated as a `formatted` with default/inherited formatting options.",
"description": "Value to use for a text label. If a plain `string` is provided, it will be treated as a `formatted` with default/inherited formatting options. SDF images are not supported in formatted text and will be ignored.",
"requires": [],
"disabledBy": [],
"allowedFunctionTypes": [],
Expand Down Expand Up @@ -5829,7 +5851,7 @@
]
},
"Terrain": {
"description": "Terrain renders a terran",
"description": "A global modifier that elevates layers and markers based on a DEM data source.",
"displayName": "Terrain",
"methods": [
{
Expand Down
99 changes: 99 additions & 0 deletions ios/RCTMGL-v10/RCTMGLStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ func lineLayer(layer: inout LineLayer, reactStyle:Dictionary<String, Any>, apply
self.setLinePatternTransition(&layer, styleValue:styleValue);
} else if (prop == "lineGradient") {
self.setLineGradient(&layer, styleValue:styleValue);
} else if (prop == "lineTrimOffset") {
self.setLineTrimOffset(&layer, styleValue:styleValue);
} else {
// TODO throw exception
}
Expand Down Expand Up @@ -735,6 +737,38 @@ func lightLayer(layer: inout Light, reactStyle:Dictionary<String, Any>, applyUpd
}
}

func atmosphereLayer(layer: inout Atmosphere, reactStyle:Dictionary<String, Any>, applyUpdater: @escaping ((inout Atmosphere)->Void)->Void, isValid: @escaping () -> Bool)
{
guard self._hasReactStyle(reactStyle) else {
fatalError("Invlalid style: \(reactStyle)")
}

let styleProps = reactStyle.keys
for prop in styleProps {
if (prop == "__MAPBOX_STYLESHEET__") {
continue;
}

let styleValue = RCTMGLStyleValue.make(reactStyle[prop])

if (prop == "range") {
self.setRange(&layer, styleValue:styleValue);
} else if (prop == "color") {
self.setColor(&layer, styleValue:styleValue);
} else if (prop == "highColor") {
self.setHighColor(&layer, styleValue:styleValue);
} else if (prop == "spaceColor") {
self.setSpaceColor(&layer, styleValue:styleValue);
} else if (prop == "horizonBlend") {
self.setHorizonBlend(&layer, styleValue:styleValue);
} else if (prop == "starIntensity") {
self.setStarIntensity(&layer, styleValue:styleValue);
} else {
// TODO throw exception
}
}
}




Expand Down Expand Up @@ -1036,6 +1070,15 @@ func setLineGradient(_ layer: inout LineLayer, styleValue: RCTMGLStyleValue)

}

func setLineTrimOffset(_ layer: inout LineLayer, styleValue: RCTMGLStyleValue)
{


layer.lineTrimOffset = styleValue.mglStyleValueArrayNumber();


}



func setSymbolPlacement(_ layer: inout SymbolLayer, styleValue: RCTMGLStyleValue)
Expand Down Expand Up @@ -2312,6 +2355,62 @@ func setIntensityTransition(_ layer: inout Light, styleValue: RCTMGLStyleValue)



func setRange(_ layer: inout Atmosphere, styleValue: RCTMGLStyleValue)
{


layer.range = styleValue.mglStyleValueArrayNumber();


}

func setColor(_ layer: inout Atmosphere, styleValue: RCTMGLStyleValue)
{


layer.color = styleValue.mglStyleValueColor();


}

func setHighColor(_ layer: inout Atmosphere, styleValue: RCTMGLStyleValue)
{


layer.highColor = styleValue.mglStyleValueColor();


}

func setSpaceColor(_ layer: inout Atmosphere, styleValue: RCTMGLStyleValue)
{


layer.spaceColor = styleValue.mglStyleValueColor();


}

func setHorizonBlend(_ layer: inout Atmosphere, styleValue: RCTMGLStyleValue)
{


layer.horizonBlend = styleValue.mglStyleValueNumber();


}

func setStarIntensity(_ layer: inout Atmosphere, styleValue: RCTMGLStyleValue)
{


layer.starIntensity = styleValue.mglStyleValueNumber();


}



func _hasReactStyle(_ reactStyle: Dictionary<String, Any>) -> Bool
{
return reactStyle != nil && reactStyle.keys.count > 0;
Expand Down
2 changes: 1 addition & 1 deletion javascript/components/Terrain.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const MapboxGL = NativeModules.MGLModule;
export const NATIVE_MODULE_NAME = 'RCTMGLTerrain';

/**
* Terrain renders a terran
* A global modifier that elevates layers and markers based on a DEM data source.
*/
class Terrain extends React.PureComponent {
static propTypes = {
Expand Down
Loading