From 9d091092b75fa90dda83868440ef04f43694e068 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Dietrich?= Date: Mon, 23 Sep 2019 10:54:57 +0200 Subject: added additional visibility function visible2 that directly uses a boolean --- src/Mapbox/Layer.elm | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src/Mapbox') diff --git a/src/Mapbox/Layer.elm b/src/Mapbox/Layer.elm index e441e86..1249b0a 100644 --- a/src/Mapbox/Layer.elm +++ b/src/Mapbox/Layer.elm @@ -3,7 +3,7 @@ module Mapbox.Layer exposing , background, fill, json, jsonList, symbol, line, raster, circle, fillExtrusion, heatmap, hillshade , Background, Fill, Symbol, Line, Raster, Circle, FillExtrusion, Heatmap, Hillshade , LayerAttr - , metadata, sourceLayer, minzoom, maxzoom, filter, visible + , metadata, sourceLayer, minzoom, maxzoom, filter, visible, visible2 , fillAntialias, fillColor, fillOpacity, fillOutlineColor, fillPattern, fillTranslate, fillTranslateAnchor , lineBlur, lineCap, lineColor, lineDasharray, lineGapWidth, lineGradient, lineJoin, lineMiterLimit, lineOffset, lineOpacity, linePattern, lineRoundLimit, lineTranslate, lineTranslateAnchor, lineWidth , circleBlur, circleColor, circleOpacity, circlePitchAlignment, circlePitchScale, circleRadius, circleStrokeColor, circleStrokeOpacity, circleStrokeWidth, circleTranslate, circleTranslateAnchor @@ -54,7 +54,7 @@ Paint properties are applied later in the rendering process. Changes to a paint ### General Attributes @docs LayerAttr -@docs metadata, sourceLayer, minzoom, maxzoom, filter, visible +@docs metadata, sourceLayer, minzoom, maxzoom, filter, visible, visible2 ### Fill Attributes @@ -354,6 +354,21 @@ visible vis = Layout "visibility" <| Expression.encode <| Expression.ifElse vis (Expression.str "visible") (Expression.str "none") +{-| Directly use a boolean value to set a layer to visible or not. +-} +visible2 : Bool -> LayerAttr any +visible2 vis = + (if vis then + "visible" + + else + "none" + ) + |> Expression.str + |> Expression.encode + |> Layout "visibility" + + -- Fill -- cgit v1.2.3