aboutsummaryrefslogtreecommitdiffstats
path: root/src/Mapbox
diff options
context:
space:
mode:
Diffstat (limited to 'src/Mapbox')
-rw-r--r--src/Mapbox/Cmd/Option.elm11
-rw-r--r--src/Mapbox/Cmd/Template.elm20
-rw-r--r--src/Mapbox/Element.elm15
-rw-r--r--src/Mapbox/Expression.elm10
-rw-r--r--src/Mapbox/Helpers.elm2
-rw-r--r--src/Mapbox/Layer.elm8
-rw-r--r--src/Mapbox/Source.elm18
-rw-r--r--src/Mapbox/Style.elm6
8 files changed, 44 insertions, 46 deletions
diff --git a/src/Mapbox/Cmd/Option.elm b/src/Mapbox/Cmd/Option.elm
index 2e3321d..4c6374f 100644
--- a/src/Mapbox/Cmd/Option.elm
+++ b/src/Mapbox/Cmd/Option.elm
@@ -1,4 +1,4 @@
-module Mapbox.Cmd.Option exposing (duration, easing, offset, animate, curve, minZoom, speed, screenSpeed, maxDuration, center, zoom, bearing, pitch, around, padding, Padding, linear, maxZoom)
+module Mapbox.Cmd.Option exposing (Padding, animate, around, bearing, center, curve, duration, easing, linear, maxDuration, maxZoom, minZoom, offset, padding, pitch, screenSpeed, speed, zoom)
{-|
@@ -25,12 +25,11 @@ Options common to `jumpTo`, `easeTo`, and `flyTo`, controlling the desired locat
-}
-import Mapbox.Helpers exposing (encodePair)
import Json.Encode as Encode exposing (Value)
-import Mapbox.Cmd.Internal as Internal exposing (Option(..), Supported)
-import Mapbox.Helpers exposing (encodePair)
import LngLat exposing (LngLat)
+import Mapbox.Cmd.Internal as Internal exposing (Option(..), Supported)
import Mapbox.Expression exposing (DataExpression, Expression)
+import Mapbox.Helpers exposing (encodePair)
{-| The animation's duration, measured in milliseconds.
@@ -176,7 +175,7 @@ maxDuration =
-}
layers : List String -> Option { a | layers : Supported }
layers =
- List.map Encode.string >> Encode.list >> Option "layers"
+ Encode.list Encode.string >> Option "layers"
{-| A filter to limit query results.
@@ -197,4 +196,4 @@ intersectsPoint =
-}
intersectsBox : ( LngLat, LngLat ) -> Option { a | query : Supported }
intersectsBox =
- encodePair (LngLat.encodeAsPair) >> Option "query"
+ encodePair LngLat.encodeAsPair >> Option "query"
diff --git a/src/Mapbox/Cmd/Template.elm b/src/Mapbox/Cmd/Template.elm
index 4d412d5..3dbf66d 100644
--- a/src/Mapbox/Cmd/Template.elm
+++ b/src/Mapbox/Cmd/Template.elm
@@ -1,4 +1,4 @@
-module Mapbox.Cmd.Template exposing (Id, Outgoing, Option, Supported, panBy, panTo, zoomTo, zoomIn, zoomOut, rotateTo, jumpTo, easeTo, flyTo, stop, fitBounds, resize)
+module Mapbox.Cmd.Template exposing (Id, Option, Outgoing, Supported, easeTo, fitBounds, flyTo, jumpTo, panBy, panTo, resize, rotateTo, stop, zoomIn, zoomOut, zoomTo)
{-| This module has a bunch of essentially imperative commands for your map.
@@ -27,9 +27,9 @@ You can of course customize the module you copy into your codebase to support th
import Json.Decode as Decode
import Json.Encode as Encode exposing (Value)
+import LngLat exposing (LngLat)
import Mapbox.Cmd.Internal as Internal exposing (Option(..), Supported)
import Mapbox.Helpers exposing (encodePair)
-import LngLat exposing (LngLat)
{-| The type of a port that you need to provide for this module to work.
@@ -367,30 +367,30 @@ queryRenderedFeatures prt id reqId options =
-}
queryResults : ((Value -> msg) -> Sub msg) -> (Int -> ( LngLat, LngLat ) -> response) -> (Int -> List Value -> response) -> (String -> response) -> (response -> msg) -> Sub msg
-queryResults prt getBounds queryRenderedFeatures error tagger =
- prt (decodeResponse getBounds queryRenderedFeatures error >> tagger)
+queryResults prt getBounds_ queryRenderedFeatures_ error_ tagger =
+ prt (decodeResponse getBounds_ queryRenderedFeatures_ error_ >> tagger)
-responseDecoder getBounds queryRenderedFeatures =
+responseDecoder getBounds_ queryRenderedFeatures_ =
Decode.field "type" Decode.string
|> Decode.andThen
(\s ->
case s of
"getBounds" ->
- Decode.map2 getBounds (Decode.field "id" Decode.int) (Decode.field "bounds" (decodePair LngLat.decodeFromPair))
+ Decode.map2 getBounds_ (Decode.field "id" Decode.int) (Decode.field "bounds" (decodePair LngLat.decodeFromPair))
"queryRenderedFeatures" ->
- Decode.map2 queryRenderedFeatures (Decode.field "id" Decode.int) (Decode.field "features" (Decode.list Decode.value))
+ Decode.map2 queryRenderedFeatures_ (Decode.field "id" Decode.int) (Decode.field "features" (Decode.list Decode.value))
_ ->
Decode.fail <| "Unrecognized response type: " ++ s
)
-decodeResponse getBounds queryRenderedFeatures error value =
- case Decode.decodeValue (responseDecoder getBounds queryRenderedFeatures) value of
+decodeResponse getBounds_ queryRenderedFeatures_ error_ value =
+ case Decode.decodeValue (responseDecoder getBounds_ queryRenderedFeatures_) value of
Ok res ->
res
Err e ->
- error e
+ error_ (Decode.errorToString e)
diff --git a/src/Mapbox/Element.elm b/src/Mapbox/Element.elm
index 14b6873..b9cd74c 100644
--- a/src/Mapbox/Element.elm
+++ b/src/Mapbox/Element.elm
@@ -20,7 +20,7 @@ module Mapbox.Element exposing (EventData, MapboxAttr, TouchEvent, css, eventFea
import Html exposing (Attribute, Html, node)
import Html.Attributes exposing (attribute, property)
-import Html.Events exposing (Options)
+import Html.Events
import Json.Decode as Decode exposing (Decoder, Value)
import Json.Encode as Encode
import LngLat exposing (LngLat)
@@ -127,8 +127,7 @@ This needs more design before release.
-}
featureState : List ( Value, List ( String, Value ) ) -> MapboxAttr msg
featureState =
- List.map (\( feature, state ) -> Encode.list [ feature, Encode.object state ])
- >> Encode.list
+ Encode.list (\( feature, state ) -> Encode.list identity [ feature, Encode.object state ])
>> property "featureState"
>> MapboxAttr
@@ -150,7 +149,7 @@ a lot of data. Here you can specify which layers you want to search for intersec
-}
eventFeaturesLayers : List String -> MapboxAttr msg
eventFeaturesLayers =
- List.map Encode.string >> Encode.list >> property "eventFeaturesLayers" >> MapboxAttr
+ Encode.list Encode.string >> property "eventFeaturesLayers" >> MapboxAttr
{-| This allows you to use other events not provided by this libary.
@@ -158,9 +157,9 @@ eventFeaturesLayers =
See <https://www.mapbox.com/mapbox-gl-js/api/#map.event> for all supported events.
-}
-onWithOptions : String -> Options -> Decoder msg -> MapboxAttr msg
-onWithOptions type_ opts decoder =
- Html.Events.onWithOptions type_ opts decoder |> MapboxAttr
+on : String -> Decoder msg -> MapboxAttr msg
+on type_ decoder =
+ Html.Events.on type_ decoder |> MapboxAttr
{-| `point` is the coordinates in pixels in screen space.
@@ -199,7 +198,7 @@ type alias TouchEvent =
decodePoint =
- Decode.map2 (,) (Decode.field "x" Decode.int) (Decode.field "y" Decode.int)
+ Decode.map2 (\a b -> ( a, b )) (Decode.field "x" Decode.int) (Decode.field "y" Decode.int)
decodeEventData =
diff --git a/src/Mapbox/Expression.elm b/src/Mapbox/Expression.elm
index d800188..0206a0c 100644
--- a/src/Mapbox/Expression.elm
+++ b/src/Mapbox/Expression.elm
@@ -236,7 +236,7 @@ The expressions in this section can be used to add conditional logic to your sty
Strings can be compared with a collator for locale specific comparisons:
-@docs isEqualWithCollator, notEqualWithCollator,lessThanWithCollator, lessThanOrEqualWithCollator, greaterThanWithCollator, greaterThanOrEqualWithCollator
+@docs isEqualWithCollator, notEqualWithCollator, lessThanWithCollator, lessThanOrEqualWithCollator, greaterThanWithCollator, greaterThanOrEqualWithCollator
Logical operators:
@@ -657,7 +657,7 @@ rasterResamplingNearest =
{-| -}
rgba : Float -> Float -> Float -> Float -> Expression exprType Color
rgba r g b a =
- Expression (Json.Encode.string ("rgba" ++ Basics.toString ( r, g, b, a )))
+ Expression (Json.Encode.string ("rgba(" ++ String.fromFloat r ++ ", " ++ String.fromFloat g ++ ", " ++ String.fromFloat b ++ ", " ++ String.fromFloat a ++ ")"))
{-| -}
@@ -710,7 +710,7 @@ strings =
list : List (Expression exprType a) -> Expression exprType (Array a)
list =
- List.map encode >> Json.Encode.list >> Expression >> call1 "literal"
+ Json.Encode.list encode >> Expression >> call1 "literal"
{-| Returns a `Collator` for use in locale-dependent comparison operations. The first argument specifies if the comparison should be case sensitive. The second specifies if it is diacritic sensitive. The final locale argument specifies the IETF language tag of the locale to use.
@@ -718,7 +718,7 @@ list =
collator : Expression e1 Bool -> Expression e2 Bool -> Expression e3 String -> Expression e4 Collator
collator (Expression caseSensitive) (Expression diacriticSensitive) (Expression locale) =
Expression
- (Json.Encode.list
+ (Json.Encode.list identity
(Json.Encode.string "collator"
:: [ Json.Encode.object
[ ( "case-sensitive", caseSensitive )
@@ -881,7 +881,7 @@ calln n expressions =
call name args =
- Expression (Json.Encode.list (Json.Encode.string name :: args))
+ Expression (Json.Encode.list identity (Json.Encode.string name :: args))
{-| Retrieves a property value from the current feature's state. Returns null if the requested property is not present on the feature's state. A feature's state is not part of the GeoJSON or vector tile data, and must be set programmatically on each feature. Note that `featureState` can only be used with paint properties that support data-driven styling.
diff --git a/src/Mapbox/Helpers.elm b/src/Mapbox/Helpers.elm
index ed66d37..0f164ac 100644
--- a/src/Mapbox/Helpers.elm
+++ b/src/Mapbox/Helpers.elm
@@ -15,4 +15,4 @@ encodeAnchor v =
encodePair encoder ( a, b ) =
- Encode.list [ encoder a, encoder b ]
+ Encode.list encoder [ a, b ]
diff --git a/src/Mapbox/Layer.elm b/src/Mapbox/Layer.elm
index ce0fa67..3d75373 100644
--- a/src/Mapbox/Layer.elm
+++ b/src/Mapbox/Layer.elm
@@ -299,16 +299,16 @@ encodeAttrs attrs =
let
{ top, layout, paint } =
List.foldl
- (\attr ({ top, layout, paint } as lists) ->
+ (\attr lists ->
case attr of
Top key val ->
- { lists | top = ( key, val ) :: top }
+ { lists | top = ( key, val ) :: lists.top }
Paint key val ->
- { lists | paint = ( key, val ) :: paint }
+ { lists | paint = ( key, val ) :: lists.paint }
Layout key val ->
- { lists | layout = ( key, val ) :: layout }
+ { lists | layout = ( key, val ) :: lists.layout }
)
{ top = [], layout = [], paint = [] }
attrs
diff --git a/src/Mapbox/Source.elm b/src/Mapbox/Source.elm
index 5cc571d..8cccfd8 100644
--- a/src/Mapbox/Source.elm
+++ b/src/Mapbox/Source.elm
@@ -120,7 +120,7 @@ getId (Source k _) =
-}
bounds : LngLat -> LngLat -> SourceOption any
bounds sw ne =
- SourceOption "bounds" (Json.Encode.list [ Json.Encode.float sw.lng, Json.Encode.float sw.lat, Json.Encode.float sw.lng, Json.Encode.float sw.lat ])
+ SourceOption "bounds" (Json.Encode.list Json.Encode.float [ sw.lng, sw.lat, sw.lng, sw.lat ])
{-| Minimum zoom level for which tiles are available, as in the TileJSON spec.
@@ -222,7 +222,7 @@ This takes an array of one or more tile source URLs, as in the TileJSON spec.
-}
vector : Id -> List Url -> List (SourceOption VectorSource) -> Source
vector id urls options =
- ( "tiles", Json.Encode.list (List.map Json.Encode.string urls) )
+ ( "tiles", Json.Encode.list Json.Encode.string urls )
:: ( "type", Json.Encode.string "vector" )
:: List.map (\(SourceOption k v) -> ( k, v )) options
|> Json.Encode.object
@@ -240,7 +240,7 @@ rasterFromUrl id url =
-}
raster : Id -> List Url -> List (SourceOption RasterSource) -> Source
raster id urls options =
- ( "tiles", Json.Encode.list (List.map Json.Encode.string urls) )
+ ( "tiles", Json.Encode.list Json.Encode.string urls )
:: ( "type", Json.Encode.string "raster" )
:: List.map (\(SourceOption k v) -> ( k, v )) options
|> Json.Encode.object
@@ -306,11 +306,11 @@ type alias Coords =
encodeCoordinates : Coords -> Value
encodeCoordinates { topLeft, topRight, bottomRight, bottomLeft } =
- Json.Encode.list
- [ LngLat.encodeAsPair topLeft
- , LngLat.encodeAsPair topRight
- , LngLat.encodeAsPair bottomRight
- , LngLat.encodeAsPair bottomLeft
+ Json.Encode.list LngLat.encodeAsPair
+ [ topLeft
+ , topRight
+ , bottomRight
+ , bottomLeft
]
@@ -331,7 +331,7 @@ image id url coordinates =
video : Id -> List Url -> Coords -> Source
video id urls coordinates =
[ ( "type", Json.Encode.string "video" )
- , ( "urls", Json.Encode.list (List.map Json.Encode.string urls) )
+ , ( "urls", Json.Encode.list Json.Encode.string urls )
, ( "coordinates", encodeCoordinates coordinates )
]
|> Json.Encode.object
diff --git a/src/Mapbox/Style.elm b/src/Mapbox/Style.elm
index 500cf47..97eac31 100644
--- a/src/Mapbox/Style.elm
+++ b/src/Mapbox/Style.elm
@@ -2,7 +2,7 @@ module Mapbox.Style exposing (Light, MiscAttr, Style(..), StyleDef, Transition,
{-| A Mapbox style is a document that defines the visual appearance of a map: what data to draw, the order to draw it in, and how to style the data when drawing it. A style document is a JSON object with specific root level and nested properties. This specification defines and describes these properties.
-@docs Style, encode , StyleDef
+@docs Style, encode, StyleDef
### Light
@@ -31,7 +31,7 @@ You can also use one of these predefined styles.
import Array exposing (Array)
import Json.Encode as Encode exposing (Value)
import LngLat exposing (LngLat)
-import Mapbox.Expression exposing (Anchor(Viewport), CameraExpression, Color, Expression, float, floats, rgba)
+import Mapbox.Expression exposing (Anchor(..), CameraExpression, Color, Expression, float, floats, rgba)
import Mapbox.Helpers exposing (encodeAnchor)
import Mapbox.Layer exposing (Layer)
import Mapbox.Source exposing (Source)
@@ -95,7 +95,7 @@ encode style =
, ( "transition", encodeTransition styleDef.transition )
, ( "light", encodeLight styleDef.light )
, ( "sources", Encode.object <| List.map (\source -> ( Mapbox.Source.getId source, Mapbox.Source.encode source )) styleDef.sources )
- , ( "layers", Encode.list (List.map Mapbox.Layer.encode styleDef.layers) )
+ , ( "layers", Encode.list Mapbox.Layer.encode styleDef.layers )
]
++ List.map (\(MiscAttr key value) -> ( key, value )) styleDef.misc
|> Encode.object