From 5b7ca1d3a6b608b1c31d6b06096771a1585bcbc8 Mon Sep 17 00:00:00 2001 From: Jakub Hampl Date: Thu, 21 Jun 2018 15:49:00 +0100 Subject: Add Mapbox 0.46 compatibility and features --- src/Mapbox/Element.elm | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'src/Mapbox/Element.elm') diff --git a/src/Mapbox/Element.elm b/src/Mapbox/Element.elm index 73b569f..13f5f00 100644 --- a/src/Mapbox/Element.elm +++ b/src/Mapbox/Element.elm @@ -1,4 +1,4 @@ -module Mapbox.Element exposing (map, css, MapboxAttr, token, id, maxZoom, minZoom, maxBounds, LngLat, renderWorldCopies, EventData, TouchEvent, eventFeaturesFilter, eventFeaturesLayers, onMouseDown, onMouseUp, onMouseOver, onMouseMove, onClick, onDblClick, onMouseOut, onContextMenu, onZoom, onZoomStart, onZoomEnd, onRotate, onRotateStart, onRotateEnd, onTouchEnd, onTouchMove, onTouchCancel, controlledMap, Viewport) +module Mapbox.Element exposing (map, css, MapboxAttr, token, id, maxZoom, minZoom, maxBounds, LngLat, renderWorldCopies, featureState, EventData, TouchEvent, eventFeaturesFilter, eventFeaturesLayers, onMouseDown, onMouseUp, onMouseOver, onMouseMove, onClick, onDblClick, onMouseOut, onContextMenu, onZoom, onZoomStart, onZoomEnd, onRotate, onRotateStart, onRotateEnd, onTouchEnd, onTouchMove, onTouchCancel, controlledMap, Viewport) {-| This library wraps a Custom Element that actually renders a map. @@ -7,7 +7,7 @@ module Mapbox.Element exposing (map, css, MapboxAttr, token, id, maxZoom, minZoo ### Attributes -@docs token, id, maxZoom, minZoom, maxBounds, LngLat, renderWorldCopies +@docs token, id, maxZoom, minZoom, maxBounds, LngLat, renderWorldCopies, featureState ### Events @@ -136,6 +136,25 @@ decodePair decoder = ) +{-| This is a declarative API for controlling states on the features. + +The API takes a bunch of GeoJSON features (these can be returned from the event listeners for example). They should at a minimum have these properties defined: + + - `source` + - `sourceLayer` (only for vector sources) + - `id` the feature's unique id + +Then you can give it a `List ( String, Value )` state. You can use this state infromation through the `Mapbox.Expression.featureState` expression. + +-} +featureState : List ( Value, List ( String, Value ) ) -> MapboxAttr msg +featureState = + List.map (\( feature, state ) -> Encode.list [ feature, Encode.object state ]) + >> Encode.list + >> property "featureState" + >> MapboxAttr + + -- Events -- cgit v1.2.3