diff options
author | André Dietrich <andre.dietrich@ovgu.de> | 2020-01-07 18:02:43 +0100 |
---|---|---|
committer | André Dietrich <andre.dietrich@ovgu.de> | 2020-01-07 18:02:43 +0100 |
commit | 1d440169042ecb74482569637f480306ad331f26 (patch) | |
tree | 80ea57140c34d738788cae8d98018915e5aa802b /src/Mapbox/Source.elm | |
parent | 42d5dacc1e2edeff15fabe507fdd6b4e335923d2 (diff) | |
parent | d07b8909baedf4740b12f0c72d61b4f111ba2af2 (diff) |
Merge branch 'master' of https://github.com/andre-dietrich/elm-mapbox
Diffstat (limited to 'src/Mapbox/Source.elm')
-rw-r--r-- | src/Mapbox/Source.elm | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/Mapbox/Source.elm b/src/Mapbox/Source.elm index 68d1862..5ca38ea 100644 --- a/src/Mapbox/Source.elm +++ b/src/Mapbox/Source.elm @@ -1,6 +1,6 @@ module Mapbox.Source exposing ( Source, SourceOption - , Id, Url + , Id, Url, decode , vector, vectorFromUrl, VectorSource , raster, tileSize, rasterFromUrl, RasterSource , rasterDEMMapbox, rasterDEMTerrarium @@ -17,7 +17,7 @@ module Mapbox.Source exposing @docs Source, SourceOption -@docs Id, Url +@docs Id, Url, decode ### Vector @@ -58,7 +58,9 @@ Tiled sources can also take the following attributes: -} +import Dict import Internal +import Json.Decode as Decode exposing (Decoder) import Json.Encode exposing (Value) import LngLat exposing (LngLat) import Mapbox.Expression as Expression exposing (DataExpression, Expression) @@ -123,6 +125,18 @@ encode (Source _ value) = {-| -} +decode : Decoder (List Source) +decode = + Decode.dict Decode.value + |> Decode.map (Dict.toList >> List.map tupleToSource) + + +tupleToSource : ( String, Value ) -> Source +tupleToSource ( id, value ) = + Source id value + + +{-| -} getId : Source -> String getId (Source k _) = k |