gampleman/elm-mapbox/1.0.0

NOTE: the latest version is 4.1.0

Mapbox.Layer

Layers specify what is actually rendered on the map and are rendered in order.

Except for layers of the background type, each layer needs to refer to a source. Layers take the data that they get from a source, optionally filter features, and then define how those features are styled.

There are two kinds of properties: Layout and Paint properties.

Layout properties are applied early in the rendering process and define how data for that layer is passed to the GPU. Changes to a layout property require an asynchronous "layout" step.

Paint properties are applied later in the rendering process. Changes to a paint property are cheap and happen synchronously.

Working with layers

type Layer

Represents a layer.

type alias SourceId =
String

All layers (except background layers) need a source

encode : Layer -> Value

Turns a layer into JSON

Layer Types

background : String -> List (LayerAttr Background) -> Layer

The background color or pattern of the map.

fill : String -> SourceId -> List (LayerAttr Fill) -> Layer

A filled polygon with an optional stroked border.

symbol : String -> SourceId -> List (LayerAttr Symbol) -> Layer

An icon or a text label.

line : String -> SourceId -> List (LayerAttr Line) -> Layer

A stroked line.

raster : String -> SourceId -> List (LayerAttr Raster) -> Layer

Raster map textures such as satellite imagery.

circle : String -> SourceId -> List (LayerAttr Circle) -> Layer

A filled circle.

fillExtrusion : String -> SourceId -> List (LayerAttr FillExtrusion) -> Layer

An extruded (3D) polygon.

heatmap : String -> SourceId -> List (LayerAttr Heatmap) -> Layer

A heatmap.

hillshade : String -> SourceId -> List (LayerAttr Hillshade) -> Layer

Client-side hillshading visualization based on DEM data. Currently, the implementation only supports Mapbox Terrain RGB and Mapzen Terrarium tiles.

type Fill
type Symbol
type Line
type Raster
type Circle
type Heatmap

General Attributes

type LayerAttr tipe
metadata : Value -> LayerAttr all

Arbitrary properties useful to track with the layer, but do not influence rendering. Properties should be prefixed to avoid collisions, like 'mapbox:'.

sourceLayer : String -> LayerAttr all

Layer to use from a vector tile source. Required for vector tile sources; prohibited for all other source types, including GeoJSON sources.

minzoom : Float -> LayerAttr all

The minimum zoom level for the layer. At zoom levels less than the minzoom, the layer will be hidden. A number between 0 and 24 inclusive.

maxzoom : Float -> LayerAttr all

The maximum zoom level for the layer. At zoom levels equal to or greater than the maxzoom, the layer will be hidden. A number between 0 and 24 inclusive.

filter : Expression any Bool -> LayerAttr all

A expression specifying conditions on source features. Only features that match the filter are displayed.

Whether this layer is displayed.

Fill Attributes

Whether or not the fill should be antialiased. Paint property. Defaults to true.

The color of the filled part of this layer. This color can be specified as rgba with an alpha component and the color's opacity will not affect the opacity of the 1px stroke, if it is used. Paint property. Defaults to #000000. Disabled by fillPattern.

The opacity of the entire fill layer. In contrast to the fillColor, this value will also affect the 1px stroke around the fill, if the stroke is used. Paint property.

Should be between 0 and 1 inclusive. Defaults to 1.

The outline color of the fill. Matches the value of fillColor if unspecified. Paint property. Disabled by fillPattern. Requires fillAntialias to be true.

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). Note that zoom-dependent expressions will be evaluated only at integer zoom levels. Paint property.

The geometry's offset. Values are [x, y] where negatives indicate left and up, respectively. Paint property. Units in pixels. Defaults to 0,0.

Controls the frame of reference for fillTranslate. Paint property. Defaults to anchorMap. Requires fillTranslate.

  • anchorMap: The fill is translated relative to the map.
  • anchorViewport: The fill is translated relative to the viewport.

Line Attributes

Blur applied to the line, in pixels. Paint property.

Should be greater than or equal to 0. Units in pixels. Defaults to 0.

The display of line endings. Layout property. Defaults to lineCapButt.

The color with which the line will be drawn. Paint property. Defaults to #000000. Disabled by linePattern.

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. Note that GeoJSON sources with lineMetrics: true specified won't render dashed lines to the expected scale. Also note that zoom-dependent expressions will be evaluated only at integer zoom levels. Paint property.

Should be greater than or equal to 0. Units in line widths. Disabled by linePattern.

Draws a line casing outside of a line's actual path. Value indicates the width of the inner gap. Paint property.

Should be greater than or equal to 0. Units in pixels. Defaults to 0.

Defines a gradient with which to color a line feature. Can only be used with GeoJSON sources that specify "lineMetrics": true. Paint property. Disabled by lineDasharray. Disabled by linePattern. Requires source to be geojson.

The display of lines when joining. Layout property. Defaults to lineJoinMiter.

Used to automatically convert miter joins to bevel joins for sharp angles. Layout property. Defaults to 2. Requires lineJoin to be miter.

The line's offset. For linear features, a positive value offsets the line to the right, relative to the direction of the line, and a negative value to the left. For polygon features, a positive value results in an inset, and a negative value results in an outset. Paint property. Units in pixels. Defaults to 0.

The opacity at which the line will be drawn. Paint property.

Should be between 0 and 1 inclusive. Defaults to 1.

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). Note that zoom-dependent expressions will be evaluated only at integer zoom levels. Paint property.

Used to automatically convert round joins to miter joins for shallow angles. Layout property. Defaults to 1.05. Requires lineJoin to be round.

The geometry's offset. Values are [x, y] where negatives indicate left and up, respectively. Paint property. Units in pixels. Defaults to 0,0.

Controls the frame of reference for lineTranslate. Paint property. Defaults to anchorMap. Requires lineTranslate.

  • anchorMap: The line is translated relative to the map.
  • anchorViewport: The line is translated relative to the viewport.

Stroke thickness. Paint property.

Should be greater than or equal to 0. Units in pixels. Defaults to 1.

Circle Attributes

Amount to blur the circle. 1 blurs the circle such that only the centerpoint is full opacity. Paint property. Defaults to 0.

The fill color of the circle. Paint property. Defaults to #000000.

The opacity at which the circle will be drawn. Paint property.

Should be between 0 and 1 inclusive. Defaults to 1.

Orientation of circle when map is pitched. Paint property. Defaults to anchorViewport.

  • anchorMap: The circle is aligned to the plane of the map.
  • anchorViewport: The circle is aligned to the plane of the viewport.

Controls the scaling behavior of the circle when the map is pitched. Paint property. Defaults to anchorMap.

  • anchorMap: Circles are scaled according to their apparent distance to the camera.
  • anchorViewport: Circles are not scaled.

Circle radius. Paint property.

Should be greater than or equal to 0. Units in pixels. Defaults to 5.

The stroke color of the circle. Paint property. Defaults to #000000.

The opacity of the circle's stroke. Paint property.

Should be between 0 and 1 inclusive. Defaults to 1.

The width of the circle's stroke. Strokes are placed outside of the circleRadius. Paint property.

Should be greater than or equal to 0. Units in pixels. Defaults to 0.

The geometry's offset. Values are [x, y] where negatives indicate left and up, respectively. Paint property. Units in pixels. Defaults to 0,0.

Controls the frame of reference for circleTranslate. Paint property. Defaults to anchorMap. Requires circleTranslate.

  • anchorMap: The circle is translated relative to the map.
  • anchorViewport: The circle is translated relative to the viewport.

Heatmap Attributes

Defines the color of each pixel based on its density value in a heatmap. The value should be an Expression that uses heatmapDensity as input. Defaults to:

  E.heatmapDensity
  |> E.interpolate E.Linear
    [ (0.0, rgba 0 0 255 0)
    , (0.1, rgba 65 105 225 1)
    , (0.3, rgba 0 255 255 1)
    , (0.5, rgba 0 255 0 1)
    , (0.7, rgba 255 255 0 1)
    , (1.0, rgba 255 0 0 1)] Paint property.

Similar to heatmapWeight but controls the intensity of the heatmap globally. Primarily used for adjusting the heatmap based on zoom level. Paint property.

Should be greater than or equal to 0. Defaults to 1.

The global opacity at which the heatmap layer will be drawn. Paint property.

Should be between 0 and 1 inclusive. Defaults to 1.

Radius of influence of one heatmap point in pixels. Increasing the value makes the heatmap smoother, but less detailed. Paint property.

Should be greater than or equal to 1. Units in pixels. Defaults to 30.

A measure of how much an individual point contributes to the heatmap. A value of 10 would be equivalent to having 10 points of weight 1 in the same spot. Especially useful when combined with clustering. Paint property.

Should be greater than or equal to 0. Defaults to 1.

FillExtrusion Attributes

The height with which to extrude the base of this layer. Must be less than or equal to fillExtrusionHeight. Paint property.

Should be greater than or equal to 0. Units in meters. Defaults to 0. Requires fillExtrusionHeight.

The base color of the extruded fill. The extrusion's surfaces will be shaded differently based on this color in combination with the root light settings. If this color is specified as rgba with an alpha component, the alpha component will be ignored; use fillExtrusionOpacity to set layer opacity. Paint property. Defaults to #000000. Disabled by fillExtrusionPattern.

The height with which to extrude this layer. Paint property.

Should be greater than or equal to 0. Units in meters. Defaults to 0.

The opacity of the entire fill extrusion layer. This is rendered on a per-layer, not per-feature, basis, and data-driven styling is not available. Paint property.

Should be between 0 and 1 inclusive. Defaults to 1.

Name of image in sprite to use for drawing images on extruded fills. For seamless patterns, image width and height must be a factor of two (2, 4, 8, ..., 512). Note that zoom-dependent expressions will be evaluated only at integer zoom levels. Paint property.

The geometry's offset. Values are [x, y] where negatives indicate left and up (on the flat plane), respectively. Paint property. Units in pixels. Defaults to 0,0.

Controls the frame of reference for fillExtrusionTranslate. Paint property. Defaults to anchorMap. Requires fillExtrusionTranslate.

  • anchorMap: The fill extrusion is translated relative to the map.
  • anchorViewport: The fill extrusion is translated relative to the viewport.

Symbol Attributes

If true, the icon will be visible even if it collides with other previously drawn symbols. Layout property. Defaults to false. Requires iconImage.

Part of the icon placed closest to the anchor. Layout property. Defaults to positionCenter. Requires iconImage.

The color of the icon. This can only be used with sdf icons. Paint property. Defaults to #000000. Requires iconImage.

Fade out the halo towards the outside. Paint property.

Should be greater than or equal to 0. Units in pixels. Defaults to 0. Requires iconImage.

The color of the icon's halo. Icon halos can only be used with SDF icons. Paint property. Defaults to rgba 0 0 0 0. Requires iconImage.

Distance of halo to the icon outline. Paint property.

Should be greater than or equal to 0. Units in pixels. Defaults to 0. Requires iconImage.

If true, other symbols can be visible even if they collide with the icon. Layout property. Defaults to false. Requires iconImage.

Name of image in sprite to use for drawing an image background. Layout property.

If true, the icon may be flipped to prevent it from being rendered upside-down. Layout property. Defaults to false. Requires iconImage. Requires iconRotationAlignment to be map. Requires symbolPlacement to be symbolPlacementLine, or symbolPlacementLineCenter.

iconOffset : Expression any (Array Float) -> LayerAttr Symbol

Offset distance of icon from its anchor. Positive values indicate right and down, while negative values indicate left and up. Each component is multiplied by the value of iconSize to obtain the final offset in pixels. When combined with iconRotate the offset will be as if the rotated direction was up. Layout property. Defaults to 0,0. Requires iconImage.

The opacity at which the icon will be drawn. Paint property.

Should be between 0 and 1 inclusive. Defaults to 1. Requires iconImage.

If true, text will display without their corresponding icons when the icon collides with other symbols and the text does not. Layout property. Defaults to false. Requires iconImage. Requires textField.

Size of the additional area around the icon bounding box used for detecting symbol collisions. Layout property.

Should be greater than or equal to 0. Units in pixels. Defaults to 2. Requires iconImage.

Orientation of icon when map is pitched. Layout property. Defaults to anchorAuto. Requires iconImage.

  • anchorMap: The icon is aligned to the plane of the map.
  • anchorViewport: The icon is aligned to the plane of the viewport.
  • anchorAuto: Automatically matches the value of iconRotationAlignment.

Rotates the icon clockwise. Layout property. Units in degrees. Defaults to 0. Requires iconImage.

In combination with symbolPlacement, determines the rotation behavior of icons. Layout property. Defaults to anchorAuto. Requires iconImage.

  • anchorMap: When symbolPlacement is set to symbolPlacementPoint, aligns icons east-west. When symbolPlacement is set to symbolPlacementLine or symbolPlacementLineCenter, aligns icon x-axes with the line.
  • anchorViewport: Produces icons whose x-axes are aligned with the x-axis of the viewport, regardless of the value of symbolPlacement.
  • anchorAuto: When symbolPlacement is set to symbolPlacementPoint, this is equivalent to anchorViewport. When symbolPlacement is set to symbolPlacementLine or symbolPlacementLineCenter, this is equivalent to anchorMap.

Scales the original size of the icon by the provided factor. The new pixel size of the image will be the original pixel size multiplied by iconSize. 1 is the original size; 3 triples the size of the image. Layout property.

Should be greater than or equal to 0. Units in factor of the original icon size. Defaults to 1. Requires iconImage.

Scales the icon to fit around the associated text. Layout property. Defaults to textFitNone. Requires iconImage. Requires textField.

Size of the additional area added to dimensions determined by iconTextFit, in clockwise order: top, right, bottom, left. Layout property. Units in pixels. Defaults to 0,0,0,0. Requires iconImage. Requires textField. Requires iconTextFit to be textFitBoth, or textFitWidth, or textFitHeight.

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. Paint property. Units in pixels. Defaults to 0,0. Requires iconImage.

Controls the frame of reference for iconTranslate. Paint property. Defaults to anchorMap. Requires iconImage. Requires iconTranslate.

  • anchorMap: Icons are translated relative to the map.
  • anchorViewport: Icons are translated relative to the viewport.

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. Layout property. Defaults to false.

Label placement relative to its geometry. Layout property. Defaults to symbolPlacementPoint.

Distance between two symbol anchors. Layout property.

Should be greater than or equal to 1. Units in pixels. Defaults to 250. Requires symbolPlacement to be line.

If true, the text will be visible even if it collides with other previously drawn symbols. Layout property. Defaults to false. Requires textField.

Part of the text placed closest to the anchor. Layout property. Defaults to positionCenter. Requires textField.

The color with which the text will be drawn. Paint property. Defaults to #000000. Requires textField.

Value to use for a text label. Layout property. Defaults to ``.

textFont : Expression any (Array String) -> LayerAttr Symbol

Font stack to use for displaying text. Layout property. Requires textField.

The halo's fadeout distance towards the outside. Paint property.

Should be greater than or equal to 0. Units in pixels. Defaults to 0. Requires textField.

The color of the text's halo, which helps it stand out from backgrounds. Paint property. Defaults to rgba 0 0 0 0. Requires textField.

Distance of halo to the font outline. Max text halo width is 1/4 of the font-size. Paint property.

Should be greater than or equal to 0. Units in pixels. Defaults to 0. Requires textField.

If true, other symbols can be visible even if they collide with the text. Layout property. Defaults to false. Requires textField.

Text justification options. Layout property. Defaults to textJustifyCenter. Requires textField.

If true, the text may be flipped vertically to prevent it from being rendered upside-down. Layout property. Defaults to true. Requires textField. Requires textRotationAlignment to be map. Requires symbolPlacement to be symbolPlacementLine, or symbolPlacementLineCenter.

Text tracking amount. Layout property. Units in ems. Defaults to 0. Requires textField.

Text leading value for multi-line text. Layout property. Units in ems. Defaults to 1.2. Requires textField.

Maximum angle change between adjacent characters. Layout property. Units in degrees. Defaults to 45. Requires textField. Requires symbolPlacement to be symbolPlacementLine, or symbolPlacementLineCenter.

The maximum line width for text wrapping. Layout property.

Should be greater than or equal to 0. Units in ems. Defaults to 10. Requires textField.

textOffset : Expression any (Array Float) -> LayerAttr Symbol

Offset distance of text from its anchor. Positive values indicate right and down, while negative values indicate left and up. Layout property. Units in ems. Defaults to 0,0. Requires textField.

The opacity at which the text will be drawn. Paint property.

Should be between 0 and 1 inclusive. Defaults to 1. Requires textField.

If true, icons will display without their corresponding text when the text collides with other symbols and the icon does not. Layout property. Defaults to false. Requires textField. Requires iconImage.

Size of the additional area around the text bounding box used for detecting symbol collisions. Layout property.

Should be greater than or equal to 0. Units in pixels. Defaults to 2. Requires textField.

Orientation of text when map is pitched. Layout property. Defaults to anchorAuto. Requires textField.

  • anchorMap: The text is aligned to the plane of the map.
  • anchorViewport: The text is aligned to the plane of the viewport.
  • anchorAuto: Automatically matches the value of textRotationAlignment.

Rotates the text clockwise. Layout property. Units in degrees. Defaults to 0. Requires textField.

In combination with symbolPlacement, determines the rotation behavior of the individual glyphs forming the text. Layout property. Defaults to anchorAuto. Requires textField.

  • anchorMap: When symbolPlacement is set to symbolPlacementPoint, aligns text east-west. When symbolPlacement is set to symbolPlacementLine or symbolPlacementLineCenter, aligns text x-axes with the line.
  • anchorViewport: Produces glyphs whose x-axes are aligned with the x-axis of the viewport, regardless of the value of symbolPlacement.
  • anchorAuto: When symbolPlacement is set to symbolPlacementPoint, this is equivalent to anchorViewport. When symbolPlacement is set to symbolPlacementLine or symbolPlacementLineCenter, this is equivalent to anchorMap.

Font size. Layout property.

Should be greater than or equal to 0. Units in pixels. Defaults to 16. Requires textField.

Specifies how to capitalize text, similar to the CSS textTransform property. Layout property. Defaults to textTransformNone. Requires textField.

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. Paint property. Units in pixels. Defaults to 0,0. Requires textField.

Controls the frame of reference for textTranslate. Paint property. Defaults to anchorMap. Requires textField. Requires textTranslate.

  • anchorMap: The text is translated relative to the map.
  • anchorViewport: The text is translated relative to the viewport.

Raster Attributes

Increase or reduce the brightness of the image. The value is the maximum brightness. Paint property.

Should be between 0 and 1 inclusive. Defaults to 1.

Increase or reduce the brightness of the image. The value is the minimum brightness. Paint property.

Should be between 0 and 1 inclusive. Defaults to 0.

Increase or reduce the contrast of the image. Paint property.

Should be between -1 and 1 inclusive. Defaults to 0.

Fade duration when a new tile is added. Paint property.

Should be greater than or equal to 0. Units in milliseconds. Defaults to 300.

Rotates hues around the color wheel. Paint property. Units in degrees. Defaults to 0.

The opacity at which the image will be drawn. Paint property.

Should be between 0 and 1 inclusive. Defaults to 1.

The resampling/interpolation method to use for overscaling, also known as texture magnification filter Paint property. Defaults to rasterResamplingLinear.

Increase or reduce the saturation of the image. Paint property.

Should be between -1 and 1 inclusive. Defaults to 0.

Hillshade Attributes

The shading color used to accentuate rugged terrain like sharp cliffs and gorges. Paint property. Defaults to #000000.

Intensity of the hillshade Paint property.

Should be between 0 and 1 inclusive. Defaults to 0.5.

The shading color of areas that faces towards the light source. Paint property. Defaults to #FFFFFF.

Direction of light source when map is rotated. Paint property. Defaults to anchorViewport.

  • anchorMap: The hillshade illumination is relative to the north direction.
  • anchorViewport: The hillshade illumination is relative to the top of the viewport.

The direction of the light source used to generate the hillshading with 0 as the top of the viewport if hillshadeIlluminationAnchor is set to anchorViewport and due north if hillshadeIlluminationAnchor is set to anchorMap. Paint property.

Should be between 0 and 359 inclusive. Defaults to 335.

The shading color of areas that face away from the light source. Paint property. Defaults to #000000.

Background Attributes

The color with which the background will be drawn. Paint property. Defaults to #000000. Disabled by backgroundPattern.

The opacity at which the background will be drawn. Paint property.

Should be between 0 and 1 inclusive. Defaults to 1.

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). Note that zoom-dependent expressions will be evaluated only at integer zoom levels. Paint property.