aboutsummaryrefslogtreecommitdiffstats
path: root/src/Mapbox
diff options
context:
space:
mode:
authorJakub Hampl <kopomir@gmail.com>2018-08-24 12:29:25 +0100
committerJakub Hampl <kopomir@gmail.com>2018-08-24 12:29:25 +0100
commit2e9381479d484d383238493306421327623bc4a2 (patch)
tree56a58d4501f0618b1b4fa1164e909e06e0df3daf /src/Mapbox
parentaf8b5c077da700236667ccb3cdcd736774dd9e3b (diff)
v0.48 compatibility, docs improvements, polish
Diffstat (limited to 'src/Mapbox')
-rw-r--r--src/Mapbox/Element.elm45
-rw-r--r--src/Mapbox/Expression.elm191
-rw-r--r--src/Mapbox/Helpers.elm11
-rw-r--r--src/Mapbox/Layer.elm175
-rw-r--r--src/Mapbox/Source.elm25
-rw-r--r--src/Mapbox/Style.elm11
6 files changed, 319 insertions, 139 deletions
diff --git a/src/Mapbox/Element.elm b/src/Mapbox/Element.elm
index b9cd74c..a54d645 100644
--- a/src/Mapbox/Element.elm
+++ b/src/Mapbox/Element.elm
@@ -1,4 +1,4 @@
-module Mapbox.Element exposing (EventData, MapboxAttr, TouchEvent, css, eventFeaturesFilter, eventFeaturesLayers, id, map, maxBounds, maxZoom, minZoom, onClick, onContextMenu, onDblClick, onMouseDown, onMouseMove, onMouseOut, onMouseOver, onMouseUp, onRotate, onRotateEnd, onRotateStart, onTouchCancel, onTouchEnd, onTouchMove, onZoom, onZoomEnd, onZoomStart, renderWorldCopies, token)
+module Mapbox.Element exposing (EventData, MapboxAttr, TouchEvent, css, eventFeaturesFilter, eventFeaturesLayers, featureState, id, map, maxBounds, maxZoom, minZoom, onClick, onContextMenu, onDblClick, onMouseDown, onMouseMove, onMouseOut, onMouseOver, onMouseUp, onRotate, onRotateEnd, onRotateStart, onTouchCancel, onTouchEnd, onTouchMove, onZoom, onZoomEnd, onZoomStart, renderWorldCopies, token)
{-| This library wraps a Custom Element that actually renders a map.
@@ -7,7 +7,7 @@ module Mapbox.Element exposing (EventData, MapboxAttr, TouchEvent, css, eventFea
### Attributes
-@docs token, id, maxZoom, minZoom, maxBounds, renderWorldCopies
+@docs token, id, maxZoom, minZoom, maxBounds, renderWorldCopies, featureState
### Events
@@ -67,7 +67,7 @@ You can include the required styles yourself if it fits better with the way you
-}
css : Html msg
css =
- node "link" [ attribute "href" "https://api.tiles.mapbox.com/mapbox-gl-js/v0.47.0/mapbox-gl.css", attribute "rel" "stylesheet" ] []
+ node "link" [ attribute "href" "https://api.tiles.mapbox.com/mapbox-gl-js/v0.48.0/mapbox-gl.css", attribute "rel" "stylesheet" ] []
{-| The minimum zoom level of the map (0-24).
@@ -112,17 +112,46 @@ renderWorldCopies =
Encode.bool >> property "renderWorldCopies" >> MapboxAttr
-{-| This is a declarative API for controlling states on the features.
+{-| Sometimes you need to give certain geographic features some state.
-The API takes a bunch of GeoJSON features (these can be returned from the event listeners for example). They should at a minimum have these properties defined:
+The most common is user interaction states like hover, selected, etc.
+
+The feature here is accepted as a `Value`. This is partially due to its flexibility, but in order for this to work, this must be an object with the following **top-level** propreties:
- `source`
- `sourceLayer` (only for vector sources)
- - `id` the feature's unique id
+ - `id` the feature's unique id (this must be a positive, non-zero integer).
+
+You can get these `Value`s from event listeners and pass them straight through. The state is a list of `(key, value)` pairs.
+
+You can use this state infromation through the `Mapbox.Expression.featureState` expression.
+
+ Layer.fillOpacity <|
+ E.ifElse
+ (E.toBool (E.featureState (str "hover")))
+ (float 0.9)
+ (float 0.1)
+
+Note that this attribute is quite awkward to use directly. I recommend defining some helpers that suite your situation. For example:
+
+ hoveredFeature : Value -> MapboxAttr msg
+ hoveredFeature feat =
+ Element.featureState [ ( feat, [ ( "hover", Json.Encode.bool True ) ] ) ]
+
+or
-Then you can give it a `List ( String, Value )` state. You can use this state infromation through the `Mapbox.Expression.featureState` expression.
+ dataJoins : List (Int, Float) -> MapboxAttr msg
+ dataJoins =
+ List.map (\(id, population) ->
+ (Json.Encode.object
+ [( "source", Json.Encode.string "postcodes")
+ , ("id", Json.Encode.int id)
+ ]
+ , [ ("population", Json.Encode.float population)]
+ )
+ >> Element.featureState
-This needs more design before release.
+This will make your view code much neater, by not mixing in JSON encoding directly.
-}
featureState : List ( Value, List ( String, Value ) ) -> MapboxAttr msg
diff --git a/src/Mapbox/Expression.elm b/src/Mapbox/Expression.elm
index 0206a0c..7215de2 100644
--- a/src/Mapbox/Expression.elm
+++ b/src/Mapbox/Expression.elm
@@ -1,12 +1,14 @@
module Mapbox.Expression
exposing
- ( Anchor(..)
- , AnchorAuto
+ ( Anchor
+ , Auto
, CameraExpression
, Collator
, Color
, DataExpression
, Expression
+ , FormattedString
+ , FormattedText
, Interpolation(..)
, LineCap
, LineJoin
@@ -20,9 +22,7 @@ module Mapbox.Expression
, abs
, acos
, all
- , anchorAutoAuto
- , anchorAutoMap
- , anchorAutoViewport
+ , anchorAuto
, anchorMap
, anchorViewport
, any
@@ -55,6 +55,9 @@ module Mapbox.Expression
, float
, floats
, floor
+ , fontScaledBy
+ , format
+ , formatted
, geometryType
, get
, getProperty
@@ -144,6 +147,7 @@ module Mapbox.Expression
, true
, typeof
, upcase
+ , withFont
, zoom
)
@@ -197,7 +201,7 @@ All of the types used as expression results are phantom (i.e. they don't have an
We introduce the following types:
-@docs Color, Object, Collator
+@docs Color, Object, Collator, FormattedText
(And also a bunch of Enum types, that will be documented in the Enums section).
@@ -257,6 +261,11 @@ Control flow:
@docs append, downcase, upcase, isSupportedScript, resolvedLocale
+### Formatted Text
+
+@docs format, FormattedString, formatted, fontScaledBy, withFont
+
+
### Color
@docs makeRGBColor, makeRGBAColor, rgbaChannels
@@ -281,7 +290,7 @@ Control flow:
These are required for various layer properties.
-@docs Anchor, anchorMap, anchorViewport, AnchorAuto, anchorAutoMap, anchorAutoViewport, anchorAutoAuto, Position, positionCenter, positionLeft, positionRight, positionTop, positionBottom, positionTopLeft, positionTopRight, positionBottomLeft, positionBottomRight, TextFit, textFitNone, textFitWidth, textFitHeight, textFitBoth, LineCap, lineCapButt, lineCapRound, lineCapSquare, LineJoin, lineJoinBevel, lineJoinRound, lineJoinMiter, SymbolPlacement, symbolPlacementPoint, symbolPlacementLine, symbolPlacementLineCenter, TextJustify, textJustifyLeft, textJustifyCenter, textJustifyRight, TextTransform, textTransformNone, textTransformUppercase, textTransformLowercase, RasterResampling, rasterResamplingLinear, rasterResamplingNearest
+@docs Anchor, anchorMap, anchorViewport, anchorAuto, Auto, Position, positionCenter, positionLeft, positionRight, positionTop, positionBottom, positionTopLeft, positionTopRight, positionBottomLeft, positionBottomRight, TextFit, textFitNone, textFitWidth, textFitHeight, textFitBoth, LineCap, lineCapButt, lineCapRound, lineCapSquare, LineJoin, lineJoinBevel, lineJoinRound, lineJoinMiter, SymbolPlacement, symbolPlacementPoint, symbolPlacementLine, symbolPlacementLineCenter, TextJustify, textJustifyLeft, textJustifyCenter, textJustifyRight, TextTransform, textTransformNone, textTransformUppercase, textTransformLowercase, RasterResampling, rasterResamplingLinear, rasterResamplingNearest
-}
@@ -383,48 +392,40 @@ type Collator
-- Enums
-{-| -}
-type Anchor
- = Map
- | Viewport
+{-| Encodes the relation to which something is measured or aligned to. The exact details are explained in the docs of each property supporting this. Some properties support the `anchorAuto` value, these have the type `Anchor Auto`, other don't and have the type `Anchor Never`.
+-}
+type Anchor supportsAuto
+ = Anchor
-{-| -}
-anchorMap : Expression exprType Anchor
+{-| Relativeto the map.
+-}
+anchorMap : Expression exprType (Anchor a)
anchorMap =
Expression (Json.Encode.string "map")
-{-| -}
-anchorViewport : Expression exprType Anchor
+{-| Relative to the viewport.
+-}
+anchorViewport : Expression exprType (Anchor a)
anchorViewport =
Expression (Json.Encode.string "viewport")
{-| -}
-type AnchorAuto
- = AnchorAuto
-
-
-{-| -}
-anchorAutoMap : Expression exprType AnchorAuto
-anchorAutoMap =
- Expression (Json.Encode.string "map")
-
-
-{-| -}
-anchorAutoViewport : Expression exprType AnchorAuto
-anchorAutoViewport =
- Expression (Json.Encode.string "viewport")
+type Auto
+ = Auto
-{-| -}
-anchorAutoAuto : Expression exprType AnchorAuto
-anchorAutoAuto =
+{-| Automatic behaviour, that may vary based on circumstance between viewport and map.
+-}
+anchorAuto : Expression exprType (Anchor Auto)
+anchorAuto =
Expression (Json.Encode.string "auto")
-{-| -}
+{-| Which part of the object is placed closest to the Anchor.
+-}
type Position
= Position
@@ -483,76 +484,89 @@ positionBottomRight =
Expression (Json.Encode.string "bottom-right")
-{-| -}
+{-| Scaling an icon to fit associated text.
+-}
type TextFit
= TextFit
-{-| -}
+{-| The icon is displayed at its intrinsic aspect ratio.
+-}
textFitNone : Expression exprType TextFit
textFitNone =
Expression (Json.Encode.string "none")
-{-| -}
+{-| The icon is scaled in the x-dimension to fit the width of the text.
+-}
textFitWidth : Expression exprType TextFit
textFitWidth =
Expression (Json.Encode.string "width")
-{-| -}
+{-| The icon is scaled in the y-dimension to fit the height of the text.
+-}
textFitHeight : Expression exprType TextFit
textFitHeight =
Expression (Json.Encode.string "height")
-{-| -}
+{-| The icon is scaled in both x- and y-dimensions.
+-}
textFitBoth : Expression exprType TextFit
textFitBoth =
Expression (Json.Encode.string "both")
-{-| -}
+{-| Display of line endings.
+-}
type LineCap
= LineCap
-{-| -}
+{-| A cap with a squared-off end which is drawn to the exact endpoint of the line.
+-}
lineCapButt : Expression exprType LineCap
lineCapButt =
Expression (Json.Encode.string "butt")
-{-| -}
+{-| A cap with a rounded end which is drawn beyond the endpoint of the line at a radius of one-half of the line's width and centered on the endpoint of the line.
+-}
lineCapRound : Expression exprType LineCap
lineCapRound =
Expression (Json.Encode.string "round")
-{-| -}
+{-| A cap with a squared-off end which is drawn beyond the endpoint of the line at a distance of one-half of the line's width.
+-}
lineCapSquare : Expression exprType LineCap
lineCapSquare =
Expression (Json.Encode.string "square")
-{-| -}
+{-| Display of lines when joining.
+-}
type LineJoin
= LineJoin
-{-| -}
+{-| A join with a squared-off end which is drawn beyond the endpoint of the line at a distance of one-half of the line's width.
+-}
lineJoinBevel : Expression exprType LineJoin
lineJoinBevel =
Expression (Json.Encode.string "bevel")
-{-| -}
+{-| A join with a rounded end which is drawn beyond the endpoint of the line at a radius of one-half of the line's width and centered on the endpoint of the line.
+-}
lineJoinRound : Expression exprType LineJoin
lineJoinRound =
Expression (Json.Encode.string "round")
-{-| -}
+{-| A join with a sharp, angled corner which is drawn with the outer sides beyond the endpoint of the path until they meet.
+-}
lineJoinMiter : Expression exprType LineJoin
lineJoinMiter =
Expression (Json.Encode.string "miter")
@@ -590,42 +604,49 @@ type TextJustify
= TextJustify
-{-| -}
+{-| The text is aligned to the left.
+-}
textJustifyLeft : Expression exprType TextJustify
textJustifyLeft =
Expression (Json.Encode.string "left")
-{-| -}
+{-| The text is centered.
+-}
textJustifyCenter : Expression exprType TextJustify
textJustifyCenter =
Expression (Json.Encode.string "center")
-{-| -}
+{-| The text is aligned to the right.
+-}
textJustifyRight : Expression exprType TextJustify
textJustifyRight =
Expression (Json.Encode.string "right")
-{-| -}
+{-| Specifies how to capitalize text.
+-}
type TextTransform
= TextTransform
-{-| -}
+{-| The text is not altered.
+-}
textTransformNone : Expression exprType TextTransform
textTransformNone =
Expression (Json.Encode.string "none")
-{-| -}
+{-| Forces all letters to be displayed in uppercase.
+-}
textTransformUppercase : Expression exprType TextTransform
textTransformUppercase =
Expression (Json.Encode.string "uppercase")
-{-| -}
+{-| Forces all letters to be displayed in lowercase.
+-}
textTransformLowercase : Expression exprType TextTransform
textTransformLowercase =
Expression (Json.Encode.string "lowercase")
@@ -745,6 +766,70 @@ object =
Json.Encode.object >> Expression >> call1 "literal"
+{-| Represents a richly formatted string.
+-}
+type FormattedText
+ = FormattedText
+
+
+{-| Returns formatted text containing annotations for use in mixed-format text-field entries.
+
+ Layer.textField <|
+ E.format
+ [ E.getProperty (str "name_en")
+ |> E.formatted
+ |> E.fontScaledBy (float 1.2)
+ , E.formatted (str "\n")
+ , E.getProperty (str "name")
+ |> E.formatted
+ |> E.fontScaledBy (float 0.8)
+ |> E.withFont (E.strings [ "DIN Offc Pro Medium" ])
+
+-}
+format : List FormattedString -> Expression exprType FormattedText
+format =
+ List.concatMap (\(FormattedString strExpr maybeScaleExpr maybeFontStack) -> [ strExpr, encodeFormatArgs maybeScaleExpr maybeFontStack ])
+ >> call "format"
+
+
+encodeFormatArgs maybeScaleExpr maybeFontStack =
+ [ Maybe.map (\scaleExp -> ( "font-scale", scaleExp )) maybeScaleExpr
+ , Maybe.map (\fontStack -> ( "text-font", fontStack )) maybeFontStack
+ ]
+ |> List.filterMap identity
+ |> Json.Encode.object
+
+
+{-| A FormattedText is composed of a list of FormattedString which essentially are a tuple of a string expression and some formatting information that applies to that string.
+-}
+type FormattedString
+ = FormattedString Value (Maybe Value) (Maybe Value)
+
+
+{-| Takes a String Expression and turns it into a FormattedString with default formatting.
+-}
+formatted : Expression exprType String -> FormattedString
+formatted s =
+ FormattedString (encode s) Nothing Nothing
+
+
+{-| Specifies a scaling factor relative to the text-size specified in the root layout properties.
+
+Note: this is indempotent, so calling `str "hi" |> formatted |> fontScaledBy 1.2 |> fontScaledBy 1.2` is equivalent to `str "hi" |> formatted |> fontScaledBy 1.2` rather than `str "hi" |> formatted |> fontScaledBy 1.44`.
+
+-}
+fontScaledBy : Expression exprType Float -> FormattedString -> FormattedString
+fontScaledBy scale (FormattedString s _ fs) =
+ FormattedString s (Just (encode scale)) fs
+
+
+{-| Overrides the font specified by the root layout properties.
+-}
+withFont : Expression exprType (Array String) -> FormattedString -> FormattedString
+withFont stack (FormattedString s scale _) =
+ FormattedString s scale (Just (encode stack))
+
+
-- Type Functions
diff --git a/src/Mapbox/Helpers.elm b/src/Mapbox/Helpers.elm
index 0f164ac..9f70b3e 100644
--- a/src/Mapbox/Helpers.elm
+++ b/src/Mapbox/Helpers.elm
@@ -1,17 +1,6 @@
module Mapbox.Helpers exposing (..)
import Json.Encode as Encode exposing (Value)
-import Mapbox.Expression exposing (Anchor(..))
-
-
-encodeAnchor : Anchor -> Value
-encodeAnchor v =
- case v of
- Viewport ->
- Encode.string "viewport"
-
- Map ->
- Encode.string "map"
encodePair encoder ( a, b ) =
diff --git a/src/Mapbox/Layer.elm b/src/Mapbox/Layer.elm
index 3d75373..380d5d8 100644
--- a/src/Mapbox/Layer.elm
+++ b/src/Mapbox/Layer.elm
@@ -202,7 +202,7 @@ Paint properties are applied later in the rendering process. Changes to a paint
### Raster Attributes
-@docs rasterBrightnessMax, rasterBrightnessMin, rasterContrast, rasterResampling, rasterFadeDuration, rasterHueRotate, rasterOpacity, rasterSaturation
+@docs rasterBrightnessMax, rasterBrightnessMin, rasterContrast, rasterFadeDuration, rasterHueRotate, rasterOpacity, rasterResampling, rasterSaturation
### Hillshade Attributes
@@ -218,7 +218,7 @@ Paint properties are applied later in the rendering process. Changes to a paint
import Array exposing (Array)
import Json.Encode as Encode exposing (Value)
-import Mapbox.Expression as Expression exposing (Anchor, AnchorAuto, CameraExpression, Color, DataExpression, Expression, LineCap, LineJoin, Position, RasterResampling, SymbolPlacement, TextFit, TextJustify, TextTransform)
+import Mapbox.Expression as Expression exposing (Anchor, Auto, CameraExpression, Color, DataExpression, Expression, FormattedText, LineCap, LineJoin, Position, RasterResampling, SymbolPlacement, TextFit, TextJustify, TextTransform)
{-| Represents a layer.
@@ -441,9 +441,13 @@ visible vis =
-- Fill
-{-| Controls the frame of reference for `fillTranslate`. Paint property. Defaults to `map`. Requires `fillTranslate`.
+{-| 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.
+
-}
-fillTranslateAnchor : Expression CameraExpression Anchor -> LayerAttr Fill
+fillTranslateAnchor : Expression CameraExpression (Anchor Never) -> LayerAttr Fill
fillTranslateAnchor =
Expression.encode >> Paint "fill-translate-anchor"
@@ -509,9 +513,13 @@ lineBlur =
Expression.encode >> Paint "line-blur"
-{-| Controls the frame of reference for `lineTranslate`. Paint property. Defaults to `map`. Requires `lineTranslate`.
+{-| 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.
+
-}
-lineTranslateAnchor : Expression CameraExpression Anchor -> LayerAttr Line
+lineTranslateAnchor : Expression CameraExpression (Anchor Never) -> LayerAttr Line
lineTranslateAnchor =
Expression.encode >> Paint "line-translate-anchor"
@@ -570,14 +578,14 @@ lineColor =
Expression.encode >> Paint "line-color"
-{-| The display of line endings. Layout property. Defaults to `butt`.
+{-| The display of line endings. Layout property. Defaults to `lineCapButt`.
-}
lineCap : Expression CameraExpression LineCap -> LayerAttr Line
lineCap =
Expression.encode >> Layout "line-cap"
-{-| The display of lines when joining. Layout property. Defaults to `miter`.
+{-| The display of lines when joining. Layout property. Defaults to `lineJoinMiter`.
-}
lineJoin : Expression any LineJoin -> LayerAttr Line
lineJoin =
@@ -646,23 +654,35 @@ circleRadius =
Expression.encode >> Paint "circle-radius"
-{-| Controls the frame of reference for `circleTranslate`. Paint property. Defaults to `map`. Requires `circleTranslate`.
+{-| 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.
+
-}
-circleTranslateAnchor : Expression CameraExpression Anchor -> LayerAttr Circle
+circleTranslateAnchor : Expression CameraExpression (Anchor Never) -> LayerAttr Circle
circleTranslateAnchor =
Expression.encode >> Paint "circle-translate-anchor"
-{-| Controls the scaling behavior of the circle when the map is pitched. Paint property. Defaults to `map`.
+{-| 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.
+
-}
-circlePitchScale : Expression CameraExpression Anchor -> LayerAttr Circle
+circlePitchScale : Expression CameraExpression (Anchor Never) -> LayerAttr Circle
circlePitchScale =
Expression.encode >> Paint "circle-pitch-scale"
-{-| Orientation of circle when map is pitched. Paint property. Defaults to `viewport`.
+{-| 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.
+
-}
-circlePitchAlignment : Expression CameraExpression Anchor -> LayerAttr Circle
+circlePitchAlignment : Expression CameraExpression (Anchor Never) -> LayerAttr Circle
circlePitchAlignment =
Expression.encode >> Paint "circle-pitch-alignment"
@@ -734,7 +754,17 @@ heatmapWeight =
Expression.encode >> Paint "heatmap-weight"
-{-| Defines the color of each pixel based on its density value in a heatmap. Should be an expression that uses `["heatmap-density"]` as input. Paint property. Defaults to `interpolate,linear,heatmap-density,0,rgba(0, 0, 255, 0),0.1,royalblue,0.3,cyan,0.5,lime,0.7,yellow,1,red`.
+{-| 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.
+
-}
heatmapColor : Expression CameraExpression Color -> LayerAttr Heatmap
heatmapColor =
@@ -776,9 +806,13 @@ heatmapOpacity =
-- FillExtrusion
-{-| Controls the frame of reference for `fillExtrusionTranslate`. Paint property. Defaults to `map`. Requires `fillExtrusionTranslate`.
+{-| 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.
+
-}
-fillExtrusionTranslateAnchor : Expression CameraExpression Anchor -> LayerAttr FillExtrusion
+fillExtrusionTranslateAnchor : Expression CameraExpression (Anchor Never) -> LayerAttr FillExtrusion
fillExtrusionTranslateAnchor =
Expression.encode >> Paint "fill-extrusion-translate-anchor"
@@ -841,16 +875,24 @@ fillExtrusionOpacity =
-- Symbol
-{-| Controls the frame of reference for `iconTranslate`. Paint property. Defaults to `map`. Requires `iconImage`. Requires `iconTranslate`.
+{-| 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.
+
-}
-iconTranslateAnchor : Expression CameraExpression Anchor -> LayerAttr Symbol
+iconTranslateAnchor : Expression CameraExpression (Anchor Never) -> LayerAttr Symbol
iconTranslateAnchor =
Expression.encode >> Paint "icon-translate-anchor"
-{-| Controls the frame of reference for `textTranslate`. Paint property. Defaults to `map`. Requires `textField`. Requires `textTranslate`.
+{-| 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.
+
-}
-textTranslateAnchor : Expression CameraExpression Anchor -> LayerAttr Symbol
+textTranslateAnchor : Expression CameraExpression (Anchor Never) -> LayerAttr Symbol
textTranslateAnchor =
Expression.encode >> Paint "text-translate-anchor"
@@ -926,7 +968,7 @@ textSize =
Expression.encode >> Layout "text-size"
-{-| Font stack to use for displaying text. Layout property. Defaults to `Open Sans Regular,Arial Unicode MS Regular`. Requires `textField`.
+{-| Font stack to use for displaying text. Layout property. Requires `textField`.
-}
textFont : Expression any (Array String) -> LayerAttr Symbol
textFont =
@@ -961,7 +1003,7 @@ iconOptional =
Expression.encode >> Layout "icon-optional"
-{-| 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 `line`.
+{-| 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`.
-}
iconKeepUpright : Expression CameraExpression Bool -> LayerAttr Symbol
iconKeepUpright =
@@ -982,7 +1024,7 @@ symbolAvoidEdges =
Expression.encode >> Layout "symbol-avoid-edges"
-{-| 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 `line`.
+{-| 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`.
-}
textKeepUpright : Expression CameraExpression Bool -> LayerAttr Symbol
textKeepUpright =
@@ -996,21 +1038,31 @@ textAllowOverlap =
Expression.encode >> Layout "text-allow-overlap"
-{-| In combination with `symbolPlacement`, determines the rotation behavior of icons. Layout property. Defaults to `auto`. 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`.
+
-}
-iconRotationAlignment : Expression CameraExpression AnchorAuto -> LayerAttr Symbol
+iconRotationAlignment : Expression CameraExpression (Anchor Auto) -> LayerAttr Symbol
iconRotationAlignment =
Expression.encode >> Layout "icon-rotation-alignment"
-{-| In combination with `symbolPlacement`, determines the rotation behavior of the individual glyphs forming the text. Layout property. Defaults to `auto`. 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`.
+
-}
-textRotationAlignment : Expression CameraExpression AnchorAuto -> LayerAttr Symbol
+textRotationAlignment : Expression CameraExpression (Anchor Auto) -> LayerAttr Symbol
textRotationAlignment =
Expression.encode >> Layout "text-rotation-alignment"
-{-| Label placement relative to its geometry. Layout property. Defaults to `point`.
+{-| Label placement relative to its geometry. Layout property. Defaults to `symbolPlacementPoint`.
-}
symbolPlacement : Expression CameraExpression SymbolPlacement -> LayerAttr Symbol
symbolPlacement =
@@ -1018,7 +1070,7 @@ symbolPlacement =
{-| Maximum angle change between adjacent characters. Layout property.
-Units in degrees. Defaults to `45`. Requires `textField`. Requires `symbolPlacement` to be `line`.
+Units in degrees. Defaults to `45`. Requires `textField`. Requires `symbolPlacement` to be `symbolPlacementLine`, or `symbolPlacementLineCenter`.
-}
textMaxAngle : Expression CameraExpression Float -> LayerAttr Symbol
textMaxAngle =
@@ -1047,28 +1099,38 @@ textOffset =
Expression.encode >> Layout "text-offset"
-{-| Orientation of icon when map is pitched. Layout property. Defaults to `auto`. 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`.
+
-}
-iconPitchAlignment : Expression CameraExpression AnchorAuto -> LayerAttr Symbol
+iconPitchAlignment : Expression CameraExpression (Anchor Auto) -> LayerAttr Symbol
iconPitchAlignment =
Expression.encode >> Layout "icon-pitch-alignment"
-{-| Orientation of text when map is pitched. Layout property. Defaults to `auto`. 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`.
+
-}
-textPitchAlignment : Expression CameraExpression AnchorAuto -> LayerAttr Symbol
+textPitchAlignment : Expression CameraExpression (Anchor Auto) -> LayerAttr Symbol
textPitchAlignment =
Expression.encode >> Layout "text-pitch-alignment"
-{-| Part of the icon placed closest to the anchor. Layout property. Defaults to `center`. Requires `iconImage`.
+{-| Part of the icon placed closest to the anchor. Layout property. Defaults to `positionCenter`. Requires `iconImage`.
-}
iconAnchor : Expression any Position -> LayerAttr Symbol
iconAnchor =
Expression.encode >> Layout "icon-anchor"
-{-| Part of the text placed closest to the anchor. Layout property. Defaults to `center`. Requires `textField`.
+{-| Part of the text placed closest to the anchor. Layout property. Defaults to `positionCenter`. Requires `textField`.
-}
textAnchor : Expression any Position -> LayerAttr Symbol
textAnchor =
@@ -1091,7 +1153,7 @@ textRotate =
Expression.encode >> Layout "text-rotate"
-{-| Scales the icon to fit around the associated text. Layout property. Defaults to `none`. Requires `iconImage`. Requires `textField`.
+{-| Scales the icon to fit around the associated text. Layout property. Defaults to `textFitNone`. Requires `iconImage`. Requires `textField`.
-}
iconTextFit : Expression CameraExpression TextFit -> LayerAttr Symbol
iconTextFit =
@@ -1110,7 +1172,7 @@ iconSize =
{-| 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 both,, or ,width,, or ,height.
+Units in pixels. Defaults to `0,0,0,0`. Requires `iconImage`. Requires `textField`. Requires `iconTextFit` to be `textFitBoth`, or `textFitWidth`, or `textFitHeight`.
-}
iconTextFitPadding : Expression CameraExpression (Array Float) -> LayerAttr Symbol
iconTextFitPadding =
@@ -1139,14 +1201,14 @@ textPadding =
Expression.encode >> Layout "text-padding"
-{-| Specifies how to capitalize text, similar to the CSS `textTransform` property. Layout property. Defaults to `none`. Requires `textField`.
+{-| Specifies how to capitalize text, similar to the CSS `textTransform` property. Layout property. Defaults to `textTransformNone`. Requires `textField`.
-}
textTransform : Expression any TextTransform -> LayerAttr Symbol
textTransform =
Expression.encode >> Layout "text-transform"
-{-| Text justification options. Layout property. Defaults to `center`. Requires `textField`.
+{-| Text justification options. Layout property. Defaults to `textJustifyCenter`. Requires `textField`.
-}
textJustify : Expression any TextJustify -> LayerAttr Symbol
textJustify =
@@ -1169,7 +1231,7 @@ textLetterSpacing =
Expression.encode >> Layout "text-letter-spacing"
-{-| 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`.
+{-| 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`.
-}
iconHaloColor : Expression any Color -> LayerAttr Symbol
iconHaloColor =
@@ -1183,7 +1245,7 @@ iconColor =
Expression.encode >> Paint "icon-color"
-{-| 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`.
+{-| 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`.
-}
textHaloColor : Expression any Color -> LayerAttr Symbol
textHaloColor =
@@ -1241,7 +1303,7 @@ textOpacity =
{-| Value to use for a text label. Layout property. Defaults to ``.
-}
-textField : Expression any String -> LayerAttr Symbol
+textField : Expression any FormattedText -> LayerAttr Symbol
textField =
Expression.encode >> Layout "text-field"
@@ -1291,16 +1353,6 @@ rasterContrast =
Expression.encode >> Paint "raster-contrast"
-{-| The resampling/interpolation method to use for overscaling, also known as texture magnification filter.
-
-Defaults to `rasterResamplingLinear`.
-
--}
-rasterResampling : Expression CameraExpression RasterResampling -> LayerAttr Raster
-rasterResampling =
- Expression.encode >> Paint "raster-resampling"
-
-
{-| Increase or reduce the saturation of the image. Paint property.
Should be between `-1` and `1` inclusive. Defaults to `0`.
@@ -1329,13 +1381,24 @@ rasterOpacity =
Expression.encode >> Paint "raster-opacity"
+{-| The resampling/interpolation method to use for overscaling, also known as texture magnification filter Paint property. Defaults to `rasterResamplingLinear`.
+-}
+rasterResampling : Expression CameraExpression RasterResampling -> LayerAttr Raster
+rasterResampling =
+ Expression.encode >> Paint "raster-resampling"
+
+
-- Hillshade
-{-| Direction of light source when map is rotated. Paint property. Defaults to `viewport`.
+{-| 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.
+
-}
-hillshadeIlluminationAnchor : Expression CameraExpression Anchor -> LayerAttr Hillshade
+hillshadeIlluminationAnchor : Expression CameraExpression (Anchor Never) -> LayerAttr Hillshade
hillshadeIlluminationAnchor =
Expression.encode >> Paint "hillshade-illumination-anchor"
@@ -1350,7 +1413,7 @@ hillshadeExaggeration =
Expression.encode >> Paint "hillshade-exaggeration"
-{-| The direction of the light source used to generate the hillshading with 0 as the top of the viewport if `hillshadeIlluminationAnchor` is set to `viewport` and due north if `hillshadeIlluminationAnchor` is set to `map`. Paint property.
+{-| 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