This is the technical documentation for the "layers" block in Tangram's scene file. For a conceptual overview of the way Tangram applies styles to data, see the [[Filters Overview]] and the [[Styles Overview]].
####layers
The layers
element is a required top-level element in the [[scene file]]. Individual layers are defined by a layer name under this element.
layers:
earth:
...
Required string. Can be anything except the [[reserved keywords|yaml#reserved keywords]]. No default.
layers:
landuse:
...
####data
Required parameter. Defines the beginning of a data block. Usable by top-level layers only. No default.
layers:
landuse:
data: { source: osm }
####filter
Optional object or function. No default.
A filter
element may be included once in any layer or sublayer. Only features matching the filter will be included in that layer (and its sublayers). For more on the filtering system, see [[Filters Overview]].
layers:
roads:
data: { source: osm }
filter: { kind: highway }
####draw
Required parameter. Defines the beginning of a draw block. For draw parameters, see the [[styling rules]] section.
layers:
landuse:
data: { source: osm }
draw:
...
####sublayer name Optional string. Can be anything except the [[reserved keywords|yaml#reserved keywords]]. No default.
Defines a sublayer. Sublayers can have all layer
parameters except data
, and can be nested. draw
and filter
definitions are inherited, and match simultaneously – see the [[Filters Overview]].
layers:
landuse:
data: { source: osm }
filter: ...
draw: ...
sublayer:
filter: ...
draw: ...
sublayer2:
filter: ...
draw: ...
subsublayer:
filter: ...
draw: ...
Optional parameter. Defines the beginning of a properties block. The properties
block has one kind of sub-element: custom properties, which are a key-value pair. Keys can be anything except the reserved keywords.
Custom properties may be defined here for use in filter and shader effects. These properties may be accessed through the JavaScript API, or through filter and style functions with the properties
keyword, as a convenient way to allow interactivity.
buildings:
properties:
min-height: 30
color: [.3, .3, .5]
draw:
polygons:
filter: function() { return feature.height > properties.min-height; }
color: function () { return properties.color; }
####source
Required string, naming one of the sources defined in the [[sources]] block.
data:
source: osm
####layer
Optional string, naming a top-level named object in the source datalayer. In Mapzen's Vector Tile Service, this is a FeatureCollection. If a layer
is not specified, the layer name will be used.
data:
source: osm
layer: buildings
The above layer
refers to the below object:
{"buildings":
{"type":"FeatureCollection","features":[
{"geometry":"..."}
]}
}
Because the layer name is the same as the name of the GeoJSON object, the data
object's layer
parameter can be omitted.
See the [[styling rules]] section.