--- layout: default category: reference title: Mapbox GL Style Reference permalink: / class: fill-light options: full navigation: - title: Root subnav: - title: version - title: name - title: metadata - title: center - title: zoom - title: bearing - title: pitch - title: sources - title: sprite - title: glyphs - title: transition - title: layers - title: Sources subnav: - title: Vector - title: Raster - title: GeoJSON - title: Image - title: Video - title: Sprite - title: Glyphs - title: Transition subnav: - title: duration - title: delay - title: Layers subnav: - title: Background - title: Fill - title: Line - title: Symbol - title: Raster - title: Circle - title: Types subnav: - title: Color - title: Enum - title: String - title: Boolean - title: Number - title: Array - title: Function - title: Filter ---

{{ page.title }}

The Mapbox GL style is an object that defines what data to draw, the order to draw it in, and how to style the data when drawing it. The JSON structure follows the renderer implementation very closely. It provides the basic building blocks out of which more complex styles can be built.

Key: supports interpolated functions supports piecewise constant functions transitionable

Root Properties

Top level properties on the Mapbox GL style object specify the map's appearance, sources, and layers.

{% highlight json%} { "version": 9, "name": "Mapbox Streets", "sprite": "mapbox://sprites/mapbox/streets-v9", "glyphs": "mapbox://fonts/mapbox/{fontstack}/{range}.pbf", "sources": {...}, "layers": [...] } {% endhighlight %}
Required enum. One of 9.
{% capture prop_doc %}Stylesheet version number. Must be 9.{% endcapture %}
{{prop_doc | markdownify}}
{% highlight json %} "version": 9 {% endhighlight %}
Optional string.
{% capture prop_doc %}A human-readable name for the style.{% endcapture %}
{{prop_doc | markdownify}}
{% highlight json %} "name": "Bright" {% endhighlight %}
Optional
{% capture prop_doc %}Arbitrary properties useful to track with the stylesheet, but do not influence rendering. Properties should be prefixed to avoid collisions, like 'mapbox:'.{% endcapture %}
{{prop_doc | markdownify}}
Optional array.
{% capture prop_doc %}Default map center in longitude and latitude. The style center will be used only if the map has not been positioned by other means (e.g. map options or user interaction).{% endcapture %}
{{prop_doc | markdownify}}
{% highlight json %} "center": [ -73.9749, 40.7736 ] {% endhighlight %}
Optional number.
{% capture prop_doc %}Default zoom level. The style zoom will be used only if the map has not been positioned by other means (e.g. map options or user interaction).{% endcapture %}
{{prop_doc | markdownify}}
{% highlight json %} "zoom": 12.5 {% endhighlight %}
Optional number. Units in degrees. Defaults to 0.
{% capture prop_doc %}Default bearing, in degrees. The style bearing will be used only if the map has not been positioned by other means (e.g. map options or user interaction).{% endcapture %}
{{prop_doc | markdownify}}
{% highlight json %} "bearing": 29 {% endhighlight %}
Optional number. Units in degrees. Defaults to 0.
{% capture prop_doc %}Default pitch, in degrees. Zero is perpendicular to the surface. The style pitch will be used only if the map has not been positioned by other means (e.g. map options or user interaction).{% endcapture %}
{{prop_doc | markdownify}}
{% highlight json %} "pitch": 50 {% endhighlight %}
Required sources.
{% capture prop_doc %}Data source specifications.{% endcapture %}
{{prop_doc | markdownify}}
{% highlight json %} "sources": { "mapbox-streets": { "type": "vector", "url": "mapbox://mapbox.mapbox-streets-v6" } } {% endhighlight %}
Optional string.
{% capture prop_doc %}A base URL for retrieving the sprite image and metadata. The extensions `.png`, `.json` and scale factor `@2x.png` will be automatically appended.{% endcapture %}
{{prop_doc | markdownify}}
{% highlight json %} "sprite": "mapbox://sprites/mapbox/bright-v8" {% endhighlight %}
Optional string.
{% capture prop_doc %}A URL template for loading signed-distance-field glyph sets in PBF format. Valid tokens are {fontstack} and {range}.{% endcapture %}
{{prop_doc | markdownify}}
{% highlight json %} "glyphs": "mapbox://fonts/mapbox/{fontstack}/{range}.pbf" {% endhighlight %}
Optional transition.
{% capture prop_doc %}A global transition definition to use as a default across properties.{% endcapture %}
{{prop_doc | markdownify}}
{% highlight json %} "transition": { "duration": 300, "delay": 0 } {% endhighlight %}
Required array.
{% capture prop_doc %}Layers will be drawn in the order of this array.{% endcapture %}
{{prop_doc | markdownify}}
{% highlight json %} "layers": [ { "id": "water", "source": "mapbox-streets", "source-layer": "water", "type": "fill", "paint": { "fill-color": "#00ffff" } } ] {% endhighlight %}

Sources

Sources supply data to be shown on the map. The type of source is specified by the "type" property, and must be one of vector, raster, geojson, image, video. Tiled sources (vector and raster) must specify their details in terms of the TileJSON specification. This can be done in two ways:

  • By supplying TileJSON properties such as "tiles", "minzoom", and "maxzoom" directly in the source:
    {% highlight json%} "mapbox-streets": { "type": "vector", "tiles": [ "http://a.example.com/tiles/{z}/{x}/{y}.pbf", "http://b.example.com/tiles/{z}/{x}/{y}.pbf" ], "maxzoom": 14 } {% endhighlight %}
  • By providing a "url" to a TileJSON resource:
    {% highlight json%} "mapbox-streets": { "type": "vector", "url": "http://api.example.com/tilejson.json" } {% endhighlight %}

vector

A vector tile source. Tiles must be in Mapbox Vector Tile format. All layers that use a vector source must specify a "source-layer" value. For vector tiles hosted by Mapbox, the "url" value should be of the form mapbox://mapid.

{% highlight json%} "mapbox-streets": { "type": "vector", "url": "mapbox://mapbox.mapbox-streets-v6" } {% endhighlight %}

raster

A raster tile source. For raster tiles hosted by Mapbox, the "url" value should be of the form mapbox://mapid.

{% highlight json%} "mapbox-satellite": { "type": "raster", "url": "mapbox://mapbox.satellite", "tileSize": 256 } {% endhighlight %}

geojson

A GeoJSON source. Data must be provided via a "data" property, whose value can be a URL or inline GeoJSON.

{% highlight json%} "geojson-marker": { "type": "geojson", "data": { "type": "Feature", "geometry": { "type": "Point", "coordinates": [-77.0323, 38.9131] }, "properties": { "title": "Mapbox DC", "marker-symbol": "monument" } } } {% endhighlight %}

image

An image source. The "url" value contains the image location.

The "coordinates" array contains [longitude, latitude] pairs for the image corners listed in clockwise order: top left, top right, bottom right, bottom left.

{% highlight json%} "image": { "type": "image", "url": "/mapbox-gl-js/assets/radar.gif", "coordinates": [ [-80.425, 46.437], [-71.516, 46.437], [-71.516, 37.936], [-80.425, 37.936] ] } {% endhighlight %}

video

A video source. The "urls" value is an array. For each URL in the array, a video element source will be created, in order to support same media in multiple formats supported by different browsers.

The "coordinates" array contains [longitude, latitude] pairs for the video corners listed in clockwise order: top left, top right, bottom right, bottom left.

{% highlight json%} "video": { "type": "video", "urls": [ "https://www.mapbox.com/drone/video/drone.mp4", "https://www.mapbox.com/drone/video/drone.webm" ], "coordinates": [ [37.56238816766053, -122.51596391201019], [37.56410183312965, -122.51467645168304], [37.563391708549425, -122.51309394836426], [37.56161849366671, -122.51423120498657] ] } {% endhighlight %}

Sprite

A style's sprite property supplies a URL template for loading small images to use in rendering background-pattern, fill-pattern, line-pattern, and icon-image style properties.

{% highlight json %} "sprite": "mapbox://sprites/mapbox/bright-v8" {% endhighlight %}

A valid sprite source must supply two types of files:

  • An index file, which is a JSON document containing a description of each image contained in the sprite. The content of this file must be a JSON object whose keys form identifiers to be used as the values of the above style properties, and whose values are objects describing the dimensions (width and height properties) and pixel ratio (pixelRatio) of the image and its location within the sprite (x and y). For example, a sprite containing a single image might have the following index file contents:
    {% highlight json%} { "poi": { "width": 32, "height": 32, "x": 0, "y": 0, "pixelRatio": 1 } } {% endhighlight %}
    Then the style could refer to this sprite image by creating a symbol layer with the layout property "icon-image": "poi", or with the tokenized value "icon-image": "{icon}" and vector tile features with a icon property with the value poi.
  • Image files, which are PNG images containing the sprite data.

Mapbox GL renderers will use the value of the sprite property in the style to generate the URLs for loading both files. First, for both file types, it will append @2x to the URL on high-DPI devices. Second, it will append a file extension: .json for the index file, and .png for the image file. For example, if you specified "sprite": "https://example.com/sprite", renderers would load https://example.com/sprite.json and https://example.com/sprite.png, or https://example.com/sprite@2x.json and https://example.com/sprite@2x.png.

If you are using Mapbox Studio, you will use prebuilt sprites provided by Mapbox, or you can upload custom SVG images to build your own sprite. In either case, the sprite will be built automatically and supplied by Mapbox APIs. If you want to build a sprite by hand and self-host the files, you can use spritezero-cli, a command line utility that builds Mapbox GL compatible sprite PNGs and index files from a directory of SVGs.

Glyphs

A style's glyphs property provides a URL template for loading signed-distance-field glyph sets in PBF format.

{% highlight json %} "glyphs": "mapbox://fonts/mapbox/{fontstack}/{range}.pbf" {% endhighlight %}

Transition

A style's transition property provides global transition defaults for that style.

{% highlight json %} "transition": { "duration": 300, "delay": 0 } {% endhighlight %}

Optional number. Units in milliseconds. Defaults to 300.
{% capture prop_doc %}Time allotted for transitions to complete.{% endcapture %}
{{prop_doc | markdownify}}
Optional number. Units in milliseconds. Defaults to 0.
{% capture prop_doc %}Length of time before a transition begins.{% endcapture %}
{{prop_doc | markdownify}}

Layers

A style's layers property lists all of the layers available in that style. The type of layer is specified by the "type" property, and must be one of background, fill, line, symbol, raster, circle.

{% highlight json %} "layers": [ { "id": "water", "source": "mapbox-streets", "source-layer": "water", "type": "fill", "paint": { "fill-color": "#00ffff" } } ] {% endhighlight %}

id
Required string.
{% capture prop_doc %}Unique layer name.{% endcapture %}
{{prop_doc | markdownify}}
Optional enum. One of fill, line, symbol, circle, raster, background.
{% capture prop_doc %}Rendering type of this layer.{% endcapture %}
{{prop_doc | markdownify}}
Optional
{% capture prop_doc %}Arbitrary properties useful to track with the layer, but do not influence rendering. Properties should be prefixed to avoid collisions, like 'mapbox:'.{% endcapture %}
{{prop_doc | markdownify}}
ref
Optional string.
{% capture prop_doc %}References another layer to copy `type`, `source`, `source-layer`, `minzoom`, `maxzoom`, `filter`, and `layout` properties from. This allows the layers to share processing and be more efficient.{% endcapture %}
{{prop_doc | markdownify}}
Optional string.
{% capture prop_doc %}Name of a source description to be used for this layer.{% endcapture %}
{{prop_doc | markdownify}}
Optional string.
{% capture prop_doc %}Layer to use from a vector tile source. Required if the source supports multiple layers.{% endcapture %}
{{prop_doc | markdownify}}
Optional number.
{% capture prop_doc %}The minimum zoom level on which the layer gets parsed and appears on.{% endcapture %}
{{prop_doc | markdownify}}
Optional number.
{% capture prop_doc %}The maximum zoom level on which the layer gets parsed and appears on.{% endcapture %}
{{prop_doc | markdownify}}
Optional boolean. Defaults to false.
{% capture prop_doc %}Enable querying of feature data from this layer for interactivity.{% endcapture %}
{{prop_doc | markdownify}}
Optional filter.
{% capture prop_doc %}A expression specifying conditions on source features. Only features that match the filter are displayed.{% endcapture %}
{{prop_doc | markdownify}}
Optional layout.
{% capture prop_doc %}Layout properties for the layer.{% endcapture %}
{{prop_doc | markdownify}}
Optional paint.
{% capture prop_doc %}Default paint properties for this layer.{% endcapture %}
{{prop_doc | markdownify}}
Optional paint.
{% capture prop_doc %}Class-specific paint properties for this layer. The class name is the part after the first dot.{% endcapture %}
{{prop_doc | markdownify}}

Layers have two sub-properties that determine how data from that layer is rendered: layout and paint properties.

Layout properties appear in the layer's "layout" object. They are applied early in the rendering process and define how data for that layer is passed to the GPU. For efficiency, a layer can share layout properties with another layer via the "ref" layer property, and should do so where possible. This will decrease processing time and allow the two layers will share GPU memory and other resources associated with the layer.

Paint properties are applied later in the rendering process. A layer that shares layout properties with another layer can have independent paint properties. Paint properties appear in the layer's "paint" object. Layers can also have class-specific paint properties, which are applied only when the map has a certain class name set. For example, a layer with a "paint.night" property would have those properties applied when the map has the "night" class set.

background

Layout Properties

Optional enum. One of visible, none. Defaults to visible.
{% capture prop_doc %}The display of this layer. `none` hides this layer.{% endcapture %}
{{prop_doc | markdownify}}

Paint Properties

Optional color. Defaults to #000000. Disabled by background-pattern.
{% capture prop_doc %}The color with which the background will be drawn.{% endcapture %}
{{prop_doc | markdownify}}
Optional string.
{% capture prop_doc %}Name of image in sprite to use for drawing an image background. For seamless patterns, image width and height must be a factor of two (2, 4, 8, ..., 512).{% endcapture %}
{{prop_doc | markdownify}}
Optional number. Defaults to 1.
{% capture prop_doc %}The opacity at which the background will be drawn.{% endcapture %}
{{prop_doc | markdownify}}

fill

Layout Properties

Optional enum. One of visible, none. Defaults to visible.
{% capture prop_doc %}The display of this layer. `none` hides this layer.{% endcapture %}
{{prop_doc | markdownify}}

Paint Properties

Optional boolean. Defaults to true.
{% capture prop_doc %}Whether or not the fill should be antialiased.{% endcapture %}
{{prop_doc | markdownify}}
Optional number. Defaults to 1.
{% capture prop_doc %}The opacity given to the fill color.{% endcapture %}
{{prop_doc | markdownify}}
Optional color. Defaults to #000000. Disabled by fill-pattern.
{% capture prop_doc %}The color of the fill.{% endcapture %}
{{prop_doc | markdownify}}
Optional color. Disabled by fill-pattern. Requires fill-antialias = true.
{% capture prop_doc %}The outline color of the fill. Matches the value of `fill-color` if unspecified.{% endcapture %}
{{prop_doc | markdownify}}
Optional array. Units in pixels. Defaults to 0,0.
{% capture prop_doc %}The geometry's offset. Values are [x, y] where negatives indicate left and up, respectively.{% endcapture %}
{{prop_doc | markdownify}}
Optional enum. One of map, viewport. Defaults to map. Requires fill-translate.
{% capture prop_doc %}Control whether the translation is relative to the map (north) or viewport (screen){% endcapture %}
{{prop_doc | markdownify}}
Optional string.
{% capture prop_doc %}Name of image in sprite to use for drawing image fills. For seamless patterns, image width and height must be a factor of two (2, 4, 8, ..., 512).{% endcapture %}
{{prop_doc | markdownify}}

line

Layout Properties

Optional enum. One of butt, round, square. Defaults to butt.
{% capture prop_doc %}The display of line endings.{% endcapture %}
{{prop_doc | markdownify}}
Optional enum. One of bevel, round, miter. Defaults to miter.
{% capture prop_doc %}The display of lines when joining.{% endcapture %}
{{prop_doc | markdownify}}
Optional number. Defaults to 2. Requires line-join = miter.
{% capture prop_doc %}Used to automatically convert miter joins to bevel joins for sharp angles.{% endcapture %}
{{prop_doc | markdownify}}
Optional number. Defaults to 1.05. Requires line-join = round.
{% capture prop_doc %}Used to automatically convert round joins to miter joins for shallow angles.{% endcapture %}
{{prop_doc | markdownify}}
Optional enum. One of visible, none. Defaults to visible.
{% capture prop_doc %}The display of this layer. `none` hides this layer.{% endcapture %}
{{prop_doc | markdownify}}

Paint Properties

Optional number. Defaults to 1.
{% capture prop_doc %}The opacity at which the line will be drawn.{% endcapture %}
{{prop_doc | markdownify}}
Optional color. Defaults to #000000. Disabled by line-pattern.
{% capture prop_doc %}The color with which the line will be drawn.{% endcapture %}
{{prop_doc | markdownify}}
Optional array. Units in pixels. Defaults to 0,0.
{% capture prop_doc %}The geometry's offset. Values are [x, y] where negatives indicate left and up, respectively.{% endcapture %}
{{prop_doc | markdownify}}
Optional enum. One of map, viewport. Defaults to map. Requires line-translate.
{% capture prop_doc %}Control whether the translation is relative to the map (north) or viewport (screen){% endcapture %}
{{prop_doc | markdownify}}
Optional number. Units in pixels. Defaults to 1.
{% capture prop_doc %}Stroke thickness.{% endcapture %}
{{prop_doc | markdownify}}
Optional number. Units in pixels. Defaults to 0.
{% capture prop_doc %}Draws a line casing outside of a line's actual path. Value indicates the width of the inner gap.{% endcapture %}
{{prop_doc | markdownify}}
Optional number. Units in pixels. Defaults to 0.
{% capture prop_doc %}The line's offset perpendicular to its direction. Values may be positive or negative, where positive indicates "rightwards" (if you were moving in the direction of the line) and negative indicates "leftwards."{% endcapture %}
{{prop_doc | markdownify}}
Optional number. Units in pixels. Defaults to 0.
{% capture prop_doc %}Blur applied to the line, in pixels.{% endcapture %}
{{prop_doc | markdownify}}
Optional array. Units in line widths. Disabled by line-pattern.
{% capture prop_doc %}Specifies the lengths of the alternating dashes and gaps that form the dash pattern. The lengths are later scaled by the line width. To convert a dash length to pixels, multiply the length by the current line width.{% endcapture %}
{{prop_doc | markdownify}}
Optional string.
{% capture prop_doc %}Name of image in sprite to use for drawing image lines. For seamless patterns, image width must be a factor of two (2, 4, 8, ..., 512).{% endcapture %}
{{prop_doc | markdownify}}

symbol

Layout Properties

Optional enum. One of point, line. Defaults to point.
{% capture prop_doc %}Label placement relative to its geometry. `line` can only be used on LineStrings and Polygons.{% endcapture %}
{{prop_doc | markdownify}}
Optional number. Units in pixels. Defaults to 250. Requires symbol-placement = line.
{% capture prop_doc %}Distance between two symbol anchors.{% endcapture %}
{{prop_doc | markdownify}}
Optional boolean. Defaults to false.
{% capture prop_doc %}If true, the symbols will not cross tile edges to avoid mutual collisions. Recommended in layers that don't have enough padding in the vector tile to prevent collisions, or if it is a point symbol layer placed after a line symbol layer.{% endcapture %}
{{prop_doc | markdownify}}
Optional boolean. Defaults to false. Requires icon-image.
{% capture prop_doc %}If true, the icon will be visible even if it collides with other previously drawn symbols.{% endcapture %}
{{prop_doc | markdownify}}
Optional boolean. Defaults to false. Requires icon-image.
{% capture prop_doc %}If true, other symbols can be visible even if they collide with the icon.{% endcapture %}
{{prop_doc | markdownify}}
Optional boolean. Defaults to false. Requires icon-image. Requires text-field.
{% capture prop_doc %}If true, text will display without their corresponding icons when the icon collides with other symbols and the text does not.{% endcapture %}
{{prop_doc | markdownify}}
Optional enum. One of map, viewport. Defaults to viewport. Requires icon-image.
{% capture prop_doc %}Orientation of icon when map is rotated.{% endcapture %}
{{prop_doc | markdownify}}
Optional number. Defaults to 1. Requires icon-image.
{% capture prop_doc %}Scale factor for icon. 1 is original size, 3 triples the size.{% endcapture %}
{{prop_doc | markdownify}}
Optional string.
{% capture prop_doc %}A string with {tokens} replaced, referencing the data property to pull from.{% endcapture %}
{{prop_doc | markdownify}}
Optional number. Units in degrees. Defaults to 0. Requires icon-image.
{% capture prop_doc %}Rotates the icon clockwise.{% endcapture %}
{{prop_doc | markdownify}}
Optional number. Units in pixels. Defaults to 2. Requires icon-image.
{% capture prop_doc %}Size of the additional area around the icon bounding box used for detecting symbol collisions.{% endcapture %}
{{prop_doc | markdownify}}
Optional boolean. Defaults to false. Requires icon-image. Requires icon-rotation-alignment = map. Requires symbol-placement = line.
{% capture prop_doc %}If true, the icon may be flipped to prevent it from being rendered upside-down.{% endcapture %}
{{prop_doc | markdownify}}
Optional array. Defaults to 0,0. Requires icon-image.
{% capture prop_doc %}Offset distance of icon from its anchor. Positive values indicate right and down, while negative values indicate left and up.{% endcapture %}
{{prop_doc | markdownify}}
Optional enum. One of map, viewport. Defaults to viewport. Requires text-field.
{% capture prop_doc %}Orientation of text when map is rotated.{% endcapture %}
{{prop_doc | markdownify}}
Optional string.
{% capture prop_doc %}Value to use for a text label. Feature properties are specified using tokens like {field_name}.{% endcapture %}
{{prop_doc | markdownify}}
Optional array. Defaults to Open Sans Regular,Arial Unicode MS Regular. Requires text-field.
{% capture prop_doc %}Font stack to use for displaying text.{% endcapture %}
{{prop_doc | markdownify}}
Optional number. Units in pixels. Defaults to 16. Requires text-field.
{% capture prop_doc %}Font size.{% endcapture %}
{{prop_doc | markdownify}}
Optional number. Units in em. Defaults to 10. Requires text-field.
{% capture prop_doc %}The maximum line width for text wrapping.{% endcapture %}
{{prop_doc | markdownify}}
Optional number. Units in em. Defaults to 1.2. Requires text-field.
{% capture prop_doc %}Text leading value for multi-line text.{% endcapture %}
{{prop_doc | markdownify}}
Optional number. Units in em. Defaults to 0. Requires text-field.
{% capture prop_doc %}Text tracking amount.{% endcapture %}
{{prop_doc | markdownify}}
Optional enum. One of left, center, right. Defaults to center. Requires text-field.
{% capture prop_doc %}Text justification options.{% endcapture %}
{{prop_doc | markdownify}}
Optional enum. One of center, left, right, top, bottom, top-left, top-right, bottom-left, bottom-right. Defaults to center. Requires text-field.
{% capture prop_doc %}Part of the text placed closest to the anchor.{% endcapture %}
{{prop_doc | markdownify}}
Optional number. Units in degrees. Defaults to 45. Requires text-field. Requires symbol-placement = line.
{% capture prop_doc %}Maximum angle change between adjacent characters.{% endcapture %}
{{prop_doc | markdownify}}
Optional number. Units in degrees. Defaults to 0. Requires text-field.
{% capture prop_doc %}Rotates the text clockwise.{% endcapture %}
{{prop_doc | markdownify}}
Optional number. Units in pixels. Defaults to 2. Requires text-field.
{% capture prop_doc %}Size of the additional area around the text bounding box used for detecting symbol collisions.{% endcapture %}
{{prop_doc | markdownify}}
Optional boolean. Defaults to true. Requires text-field. Requires text-rotation-alignment = map. Requires symbol-placement = line.
{% capture prop_doc %}If true, the text may be flipped vertically to prevent it from being rendered upside-down.{% endcapture %}
{{prop_doc | markdownify}}
Optional enum. One of none, uppercase, lowercase. Defaults to none. Requires text-field.
{% capture prop_doc %}Specifies how to capitalize text, similar to the CSS `text-transform` property.{% endcapture %}
{{prop_doc | markdownify}}
Optional array. Units in ems. Defaults to 0,0. Requires text-field.
{% capture prop_doc %}Offset distance of text from its anchor. Positive values indicate right and down, while negative values indicate left and up.{% endcapture %}
{{prop_doc | markdownify}}
Optional boolean. Defaults to false. Requires text-field.
{% capture prop_doc %}If true, the text will be visible even if it collides with other previously drawn symbols.{% endcapture %}
{{prop_doc | markdownify}}
Optional boolean. Defaults to false. Requires text-field.
{% capture prop_doc %}If true, other symbols can be visible even if they collide with the text.{% endcapture %}
{{prop_doc | markdownify}}
Optional boolean. Defaults to false. Requires text-field. Requires icon-image.
{% capture prop_doc %}If true, icons will display without their corresponding text when the text collides with other symbols and the icon does not.{% endcapture %}
{{prop_doc | markdownify}}
Optional enum. One of visible, none. Defaults to visible.
{% capture prop_doc %}The display of this layer. `none` hides this layer.{% endcapture %}
{{prop_doc | markdownify}}

Paint Properties

Optional number. Defaults to 1. Requires icon-image.
{% capture prop_doc %}The opacity at which the icon will be drawn.{% endcapture %}
{{prop_doc | markdownify}}
Optional color. Defaults to #000000. Requires icon-image.
{% capture prop_doc %}The color of the icon. This can only be used with sdf icons.{% endcapture %}
{{prop_doc | markdownify}}
Optional color. Defaults to rgba(0, 0, 0, 0). Requires icon-image.
{% capture prop_doc %}The color of the icon's halo. Icon halos can only be used with sdf icons.{% endcapture %}
{{prop_doc | markdownify}}
Optional number. Units in pixels. Defaults to 0. Requires icon-image.
{% capture prop_doc %}Distance of halo to the icon outline.{% endcapture %}
{{prop_doc | markdownify}}
Optional number. Units in pixels. Defaults to 0. Requires icon-image.
{% capture prop_doc %}Fade out the halo towards the outside.{% endcapture %}
{{prop_doc | markdownify}}
Optional array. Units in pixels. Defaults to 0,0. Requires icon-image.
{% capture prop_doc %}Distance that the icon's anchor is moved from its original placement. Positive values indicate right and down, while negative values indicate left and up.{% endcapture %}
{{prop_doc | markdownify}}
Optional enum. One of map, viewport. Defaults to map. Requires icon-image. Requires icon-translate.
{% capture prop_doc %}Control whether the translation is relative to the map (north) or viewport (screen).{% endcapture %}
{{prop_doc | markdownify}}
Optional number. Defaults to 1. Requires text-field.
{% capture prop_doc %}The opacity at which the text will be drawn.{% endcapture %}
{{prop_doc | markdownify}}
Optional color. Defaults to #000000. Requires text-field.
{% capture prop_doc %}The color with which the text will be drawn.{% endcapture %}
{{prop_doc | markdownify}}
Optional color. Defaults to rgba(0, 0, 0, 0). Requires text-field.
{% capture prop_doc %}The color of the text's halo, which helps it stand out from backgrounds.{% endcapture %}
{{prop_doc | markdownify}}
Optional number. Units in pixels. Defaults to 0. Requires text-field.
{% capture prop_doc %}Distance of halo to the font outline. Max text halo width is 1/4 of the font-size.{% endcapture %}
{{prop_doc | markdownify}}
Optional number. Units in pixels. Defaults to 0. Requires text-field.
{% capture prop_doc %}The halo's fadeout distance towards the outside.{% endcapture %}
{{prop_doc | markdownify}}
Optional array. Units in pixels. Defaults to 0,0. Requires text-field.
{% capture prop_doc %}Distance that the text's anchor is moved from its original placement. Positive values indicate right and down, while negative values indicate left and up.{% endcapture %}
{{prop_doc | markdownify}}
Optional enum. One of map, viewport. Defaults to map. Requires text-field. Requires text-translate.
{% capture prop_doc %}Control whether the translation is relative to the map (north) or viewport (screen).{% endcapture %}
{{prop_doc | markdownify}}

raster

Layout Properties

Optional enum. One of visible, none. Defaults to visible.
{% capture prop_doc %}The display of this layer. `none` hides this layer.{% endcapture %}
{{prop_doc | markdownify}}

Paint Properties

Optional number. Defaults to 1.
{% capture prop_doc %}The opacity at which the image will be drawn.{% endcapture %}
{{prop_doc | markdownify}}
Optional number. Units in degrees. Defaults to 0.
{% capture prop_doc %}Rotates hues around the color wheel.{% endcapture %}
{{prop_doc | markdownify}}
Optional number. Defaults to 0.
{% capture prop_doc %}Increase or reduce the brightness of the image. The value is the minimum brightness.{% endcapture %}
{{prop_doc | markdownify}}
Optional number. Defaults to 1.
{% capture prop_doc %}Increase or reduce the brightness of the image. The value is the maximum brightness.{% endcapture %}
{{prop_doc | markdownify}}
Optional number. Defaults to 0.
{% capture prop_doc %}Increase or reduce the saturation of the image.{% endcapture %}
{{prop_doc | markdownify}}
Optional number. Defaults to 0.
{% capture prop_doc %}Increase or reduce the contrast of the image.{% endcapture %}
{{prop_doc | markdownify}}
Optional number. Units in milliseconds. Defaults to 300.
{% capture prop_doc %}Fade duration when a new tile is added.{% endcapture %}
{{prop_doc | markdownify}}

circle

Layout Properties

Optional enum. One of visible, none. Defaults to visible.
{% capture prop_doc %}The display of this layer. `none` hides this layer.{% endcapture %}
{{prop_doc | markdownify}}

Paint Properties

Optional number. Units in pixels. Defaults to 5.
{% capture prop_doc %}Circle radius.{% endcapture %}
{{prop_doc | markdownify}}
Optional color. Defaults to #000000.
{% capture prop_doc %}The color of the circle.{% endcapture %}
{{prop_doc | markdownify}}
Optional number. Defaults to 0.
{% capture prop_doc %}Amount to blur the circle. 1 blurs the circle such that only the centerpoint is full opacity.{% endcapture %}
{{prop_doc | markdownify}}
Optional number. Defaults to 1.
{% capture prop_doc %}The opacity at which the circle will be drawn.{% endcapture %}
{{prop_doc | markdownify}}
Optional array. Units in pixels. Defaults to 0,0.
{% capture prop_doc %}The geometry's offset. Values are [x, y] where negatives indicate left and up, respectively.{% endcapture %}
{{prop_doc | markdownify}}
Optional enum. One of map, viewport. Defaults to map. Requires circle-translate.
{% capture prop_doc %}Control whether the translation is relative to the map (north) or viewport (screen){% endcapture %}
{{prop_doc | markdownify}}

Types

Below is a list of types and an explanation of any expression that can be applied to properties in Mapbox GL.

Color

Mapbox GL accepts a variety of syntaxes for colors - HTML-style hex values, rgb, rgba, hsl, and hsla. It also supports the predefined HTML colors names, like yellow and blue.

{% highlight json %} { "line-color": "#ff0", "line-color": "#ffff00", "line-color": "rgb(255, 255, 0)", "line-color": "rgba(255, 255, 0, 1)", "line-color": "hsl(100, 50%, 50%)", "line-color": "hsla(100, 50%, 50%, 1)", "line-color": "yellow" } {% endhighlight %}

Especially of note is the support for hsl, which can be easier to reason about than rgb().

Enum

One of a fixed list of string values. Use quotes around values.

{% highlight json %} { "text-transform": "uppercase" } {% endhighlight %}

String

A string is basically just text. In the case of Mapbox GL, you're going to put it in quotes. Strings can be anything, though pay attention to the case of text-field - it actually will refer to features, which you refer to by putting them in curly braces, as seen in the example below.

{% highlight json %} { "text-field": "{MY_FIELD}" } {% endhighlight %}

Boolean

Boolean means yes or no, so it accepts the values true or false.

{% highlight json %} { "fill-enabled": true } {% endhighlight %}

Number

A number value, often an integer or floating point (decimal number). Written without quotes.

{% highlight json %} { "text-size": 24 } {% endhighlight %}

Array

Arrays are comma-separated lists of one or more numbers in a specific order. For example, they're used in line dash arrays, in which the numbers specify intervals of line, break, and line again.

{% highlight json %} { "line-dasharray": [2, 4] } {% endhighlight %}

Function

The value for any layout or paint property may be specified as a function, allowing you to parameterize the value according to the current zoom level. Functions are written as an array of stops, where each stop is an array with two elements: a zoom level and a corresponding value. Stops must be in ascending zoom order.

Some properties support interpolated functions. The result of an interpolated function is an interpolated value between the last stop whose zoom level is less than or equal to the current zoom level, and the next stop. By default, linear interpolation is used, but you can use a different exponential base for the interpolation curve via the base property. If the current zoom is less than the first stop or greater than the last stop, the result is the value from the first or last stop respectively.

All other properties support piecewise constant functions. The result of a piecewise constant function is the value of the last stop whose zoom value is less than or equal to the current zoom level.

{% highlight json %} { "line-width": { "base": 1.5, "stops": [[5, 1], [7, 2], [11, 3]] } } {% endhighlight %}
  • baseOptional number. Default is 1.
    The exponential base of the interpolation curve. It controls the rate at which the result increases. Higher values make the result increase more towards the high end of the range. With values close to 1 the result increases linearly.
  • stopsRequired array.
    An array of zoom level and value pairs. The value can be a number or a color value for color properties.

Filter

A filter selects specific features from a layer. A filter is an array of one of the following forms:

["==", key, value] equality: key = value
["!=", key, value] inequality: keyvalue
[">", key, value] greater than: key > value
[">=", key, value] greater than or equal: keyvalue
["<", key, value] less than: key < value
["<=", key, value] less than or equal: keyvalue
["in", key, v0, ..., vn] set inclusion: key ∈ {v0, ..., vn}
["!in", key, v0, ..., vn] set exclusion: key ∉ {v0, ..., vn}
["all", f0, ..., fn] logical AND: f0 ∧ ... ∧ fn
["any", f0, ..., fn] logical OR: f0 ∨ ... ∨ fn
["none", f0, ..., fn] logical NOR: ¬f0 ∧ ... ∧ ¬fn

A filter's key must be a string that identifies a feature property, or the special key "$type", which identifies the feature type. A value (and v0, ..., vn for set operators) must be a string, number, or boolean to compare the property value against. For the "$type" key it must be one of "Point", "LineString", or "Polygon".

The binary and set operators implement strictly-typed comparisons; for example, all of the following evaluate to false: 0 < "1", 2 == "2", "true" in [true, false].

The "all", "any", and "none" filter operators are used to create compound filters. The values f0, ..., fn must be filter expressions themselves.

{% highlight json%} ["==", "$type", "LineString"] {% endhighlight %}
{% highlight json%} ["in", "class", "street_major", "street_minor", "street_limited"] {% endhighlight %}
{% highlight json%} [ "all", ["==", "class", "street_limited"], [">=", "admin_level", 3], ["!in", "$type", "Polygon"] ] {% endhighlight %}