aboutsummaryrefslogtreecommitdiffstats
path: root/src/Mapbox/Source.elm
diff options
context:
space:
mode:
authorAndré Dietrich <andre.dietrich@ovgu.de>2019-09-12 18:38:20 +0200
committerAndré Dietrich <andre.dietrich@ovgu.de>2019-09-12 18:38:20 +0200
commit1317c6de361af9d1f84abd9f0dba0408c5ef1831 (patch)
tree9a9a00e70dbcd214da9f013d6e93eec5ba7049fc /src/Mapbox/Source.elm
parent164bda0c7782d9995fb4bbf990b06ce4e9038457 (diff)
added special functions for decoding StyleDefinitions
Diffstat (limited to 'src/Mapbox/Source.elm')
-rw-r--r--src/Mapbox/Source.elm18
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