module Mapbox.Layer exposing
( Layer, SourceId, encode
, background, fill, json, jsonList, symbol, line, raster, circle, fillExtrusion, heatmap, hillshade
, Background, Fill, Symbol, Line, Raster, Circle, FillExtrusion, Heatmap, Hillshade
, LayerAttr
, metadata, sourceLayer, minzoom, maxzoom, filter, visible, visible2
, fillAntialias, fillColor, fillOpacity, fillOutlineColor, fillPattern, fillTranslate, fillTranslateAnchor
, lineBlur, lineCap, lineColor, lineDasharray, lineDasharray2, lineGapWidth, lineGradient, lineJoin, lineMiterLimit, lineOffset, lineOpacity, linePattern, lineRoundLimit, lineTranslate, lineTranslateAnchor, lineWidth
, circleBlur, circleColor, circleOpacity, circlePitchAlignment, circlePitchScale, circleRadius, circleStrokeColor, circleStrokeOpacity, circleStrokeWidth, circleTranslate, circleTranslateAnchor
, heatmapColor, heatmapIntensity, heatmapOpacity, heatmapRadius, heatmapWeight
, fillExtrusionBase, fillExtrusionColor, fillExtrusionHeight, fillExtrusionOpacity, fillExtrusionPattern, fillExtrusionTranslate, fillExtrusionTranslateAnchor, fillExtrusionVerticalGradient
, iconAllowOverlap, iconAnchor, iconColor, iconHaloBlur, iconHaloColor, iconHaloWidth, iconIgnorePlacement, iconImage, iconKeepUpright, iconOffset, iconOpacity, iconOptional, iconPadding, iconPitchAlignment, iconRotate, iconRotationAlignment, iconSize, iconTextFit, iconTextFitPadding, iconTranslate, iconTranslateAnchor, symbolAvoidEdges, symbolPlacement, symbolSortKey, symbolSpacing, symbolZOrder, textAllowOverlap, textAnchor, textColor, textField, textFont, textHaloBlur, textHaloColor, textHaloWidth, textIgnorePlacement, textJustify, textKeepUpright, textLetterSpacing, textLineHeight, textMaxAngle, textMaxWidth, textOffset, textOpacity, textOptional, textPadding, textPitchAlignment, textRadialOffset, textRotate, textRotationAlignment, textSize, textTransform, textTranslate, textTranslateAnchor, textVariableAnchor
, rasterBrightnessMax, rasterBrightnessMin, rasterContrast, rasterFadeDuration, rasterHueRotate, rasterOpacity, rasterResampling, rasterSaturation
, hillshadeAccentColor, hillshadeExaggeration, hillshadeHighlightColor, hillshadeIlluminationAnchor, hillshadeIlluminationDirection, hillshadeShadowColor
, backgroundColor, backgroundOpacity, backgroundPattern
, decode
)
{-| 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.
#### Skip to:
- [Fill Attributes](#fill-attributes)
- [Line Attributes](#line-attributes)
- [Circle Attributes](#circle-attributes)
- [Heatmap Attributes](#heatmap-attributes)
- [FillExtrusion Attributes](#fillextrusion-attributes)
- [Symbol Attributes](#symbol-attributes)
- [Raster Attributes](#raster-attributes)
- [Hillshade Attributes](#hillshade-attributes)
- [Background Attributes](#background-attributes)
### Working with layers
@docs Layer, SourceId, encode
### Layer Types
@docs background, fill, json, jsonList, symbol, line, raster, circle, fillExtrusion, heatmap, hillshade
@docs Background, Fill, Symbol, Line, Raster, Circle, FillExtrusion, Heatmap, Hillshade
### General Attributes
@docs LayerAttr
@docs metadata, sourceLayer, minzoom, maxzoom, filter, visible, visible2
### Fill Attributes
@docs fillAntialias, fillColor, fillOpacity, fillOutlineColor, fillPattern, fillTranslate, fillTranslateAnchor
### Line Attributes
@docs lineBlur, lineCap, lineColor, lineDasharray, lineDasharray2, lineGapWidth, lineGradient, lineJoin, lineMiterLimit, lineOffset, lineOpacity, linePattern, lineRoundLimit, lineTranslate, lineTranslateAnchor, lineWidth
### Circle Attributes
@docs circleBlur, circleColor, circleOpacity, circlePitchAlignment, circlePitchScale, circleRadius, circleStrokeColor, circleStrokeOpacity, circleStrokeWidth, circleTranslate, circleTranslateAnchor
### Heatmap Attributes
@docs heatmapColor, heatmapIntensity, heatmapOpacity, heatmapRadius, heatmapWeight
### FillExtrusion Attributes
@docs fillExtrusionBase, fillExtrusionColor, fillExtrusionHeight, fillExtrusionOpacity, fillExtrusionPattern, fillExtrusionTranslate, fillExtrusionTranslateAnchor, fillExtrusionVerticalGradient
### Symbol Attributes
@docs iconAllowOverlap, iconAnchor, iconColor, iconHaloBlur, iconHaloColor, iconHaloWidth, iconIgnorePlacement, iconImage, iconKeepUpright, iconOffset, iconOpacity, iconOptional, iconPadding, iconPitchAlignment, iconRotate, iconRotationAlignment, iconSize, iconTextFit, iconTextFitPadding, iconTranslate, iconTranslateAnchor, symbolAvoidEdges, symbolPlacement, symbolSortKey, symbolSpacing, symbolZOrder, textAllowOverlap, textAnchor, textColor, textField, textFont, textHaloBlur, textHaloColor, textHaloWidth, textIgnorePlacement, textJustify, textKeepUpright, textLetterSpacing, textLineHeight, textMaxAngle, textMaxWidth, textOffset, textOpacity, textOptional, textPadding, textPitchAlignment, textRadialOffset, textRotate, textRotationAlignment, textSize, textTransform, textTranslate, textTranslateAnchor, textVariableAnchor
### Raster Attributes
@docs rasterBrightnessMax, rasterBrightnessMin, rasterContrast, rasterFadeDuration, rasterHueRotate, rasterOpacity, rasterResampling, rasterSaturation
### Hillshade Attributes
@docs hillshadeAccentColor, hillshadeExaggeration, hillshadeHighlightColor, hillshadeIlluminationAnchor, hillshadeIlluminationDirection, hillshadeShadowColor
### Background Attributes
@docs backgroundColor, backgroundOpacity, backgroundPattern
### List Decoder
@docs decode
-}
import Array exposing (Array)
import Internal exposing (Supported)
import Json.Decode as Decode exposing (Decoder)
import Json.Encode as Encode exposing (Value)
import Mapbox.Expression as Expression exposing (CameraExpression, Color, DataExpression, Expression, FormattedText)
{-| Represents a layer.
-}
type Layer
= Layer Value
{-| All layers (except background layers) need a source
-}
type alias SourceId =
String
{-| -}
type Background
= BackgroundLayer
{-| -}
type Fill
= FillLayer
{-| -}
type Symbol
= SymbolLayer
{-| -}
type Line
= LineLayer
{-| -}
type Raster
= RasterLayer
{-| -}
type Circle
= CircleLayer
{-| -}
type FillExtrusion
= FillExtrusionLayer
{-| -}
type Heatmap
= HeatmapLayer
{-| -}
type Hillshade
= HillshadeLayer
{-| Turns a layer into JSON
-}
encode : Layer -> Value
encode (Layer value) =
value
layerImpl tipe id source attrs =
[ ( "id", Encode.string id )
, ( "type", Encode.string tipe )
, ( "source", Encode.string source )
]
++ encodeAttrs attrs
|> Encode.object
|> Layer
encodeAttrs attrs =
let
{ top, layout, paint } =
List.foldl
(\attr lists ->
case attr of
Top key val ->
{ lists | top = ( key, val ) :: lists.top }
Paint key val ->
{ lists | paint = ( key, val ) :: lists.paint }
Layout key val ->
{ lists | layout = ( key, val ) :: lists.layout }
)
{ top = [], layout = [], paint = [] }
attrs
in
( "layout", Encode.object layout ) :: ( "paint", Encode.object paint ) :: top
{-| The background color or pattern of the map.
-}
background : String -> List (LayerAttr Background) -> Layer
background id attrs =
[ ( "type", Encode.string "background" )
, ( "id", Encode.string id )
]
++ encodeAttrs attrs
|> Encode.object
|> Layer
{-| A filled polygon with an optional stroked border.
-}
fill : String -> SourceId -> List (LayerAttr Fill) -> Layer
fill =
layerImpl "fill"
{-| A stroked line.
-}
line : String -> SourceId -> List (LayerAttr Line) -> Layer
line =
layerImpl "line"
{-| An icon or a text label.
-}
symbol : String -> SourceId -> List (LayerAttr Symbol) -> Layer
symbol =
layerImpl "symbol"
{-| Raster map textures such as satellite imagery.
-}
raster : String -> SourceId -> List (LayerAttr Raster) -> Layer
raster =
layerImpl "raster"
{-| A filled circle.
-}
circle : String -> SourceId -> List (LayerAttr Circle) -> La
|