aboutsummaryrefslogtreecommitdiffstats
path: root/src/Mapbox/Source.elm
diff options
context:
space:
mode:
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