blob: 4ca28cc55ebc4d5e2a09e758ab6d2ce0de093f65 (
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
module Mapbox.Element exposing (..)
import Html exposing (Attribute, Html, node)
import Html.Attributes exposing (property, attribute)
import Json.Encode as Encode
import Mapbox.Style exposing (Style)
type MapboxAttr msg
= MapboxAttr (Attribute msg)
type Control msg
= Control (Html msg)
type Position
= TopLeft
| BottomLeft
| TopRight
| BottomRight
map : List (MapboxAttr msg) -> List (Control msg) -> Html msg
map attrs children =
let
props =
(List.map (\(MapboxAttr attr) -> attr) attrs)
in
node "elm-mapbox-map" props []
css : Html msg
css =
node "link" [ attribute "href" "https://api.tiles.mapbox.com/mapbox-gl-js/v0.45.0/mapbox-gl.css", attribute "rel" "stylesheet" ] []
style : Style -> MapboxAttr msg
style =
Mapbox.Style.encode >> property "mapboxStyle" >> MapboxAttr
minZoom : Float -> MapboxAttr msg
minZoom =
Encode.float >> property "minZoom" >> MapboxAttr
maxZoom : Float -> MapboxAttr msg
maxZoom =
Encode.float >> property "maxZoom" >> MapboxAttr
token : String -> MapboxAttr msg
token =
Encode.string >> property "token" >> MapboxAttr
id : String -> MapboxAttr msg
id =
attribute "id" >> MapboxAttr
type alias LngLat =
( Float, Float )
{-| sw: lnglat, ne: lnglat
-}
maxBounds : ( LngLat, LngLat ) -> MapboxAttr msg
maxBounds =
encodePair (encodePair Encode.float) >> property "maxBounds" >> MapboxAttr
renderWorldCopies : Bool -> MapboxAttr msg
renderWorldCopies =
Encode.bool >> property "renderWorldCopies" >> MapboxAttr
encodePair encoder ( a, b ) =
Encode.list [ encoder a, encoder b ]
encodePosition pos =
case pos of
TopLeft ->
Encode.string "top-left"
BottomLeft ->
Encode.string "bottom-left"
TopRight ->
Encode.string "top-right"
BottomRight ->
Encode.string "bottom-right"
--- Controlled mode
{-| Note: this property will only take effect when the map is created.
-}
controlled : MapboxAttr msg
controlled =
property "interactive" (Encode.bool False) |> MapboxAttr
|