aboutsummaryrefslogtreecommitdiffstats
path: root/examples/Light.elm
blob: a83308a7c1a33e9255eabdcb48d856582a20eb56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
module Light exposing (main)

import Html exposing (text, pre)
import Json.Encode
import Mapbox.Expression exposing (..)
import Mapbox.Layer as Layer
import Mapbox.Source as Source
import Mapbox.Style as Style


style =
    Style.encode
        { transition = Style.defaultTransition
        , light = Style.defaultLight
        , sources =
            [ Source.vectorFromUrl "composite" "mapbox://mapbox.mapbox-terrain-v2,mapbox.mapbox-streets-v7" ]
        , misc =
            [ Style.name "light"
            , Style.defaultCenter 20.39789404164037 43.22523201923144
            , Style.defaultZoomLevel 1.5967483759772743
            , Style.sprite "mapbox://sprites/seppotamminen/cjascxlb86kfe2rrvvtkd4ay1"
            , Style.glyphs "mapbox://fonts/seppotamminen/{fontstack}/{range}.pbf"
            ]
        , layers =
            [ Layer.background "background"
                [ getProperty (str "emotion")
                    |> matchesStr (rgba 55 22 32 1) [ ( "funny", rgba 20 200 20 1 ), ( "angry", rgba 200 20 20 1 ) ]
                    |> Layer.backgroundColor
                , zoom
                    |> interpolate Linear
                        [ ( 5, int 1 )
                        , ( 10, int 5 )
                        ]
                    |> Layer.circleRadius
                , makeRGBColor
                    -- red is higher when feature.properties.temperature is higher
                    (getProperty (str "temperature"))
                    -- green is always zero
                    (int 0)
                    -- blue is higher when feature.properties.temperature is lower
                    (getProperty (str "temperature") |> minus (int 100))
                    |> Layer.circleColor
                ]
            ]
        }


main =
    pre [] [ text <| Json.Encode.encode 2 style ]