aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/MapCommands.elm58
-rw-r--r--src/Mapbox/Element.elm14
-rw-r--r--src/Mapbox/Expression.elm228
-rw-r--r--src/Mapbox/Layer.elm136
-rw-r--r--src/Mapbox/Source.elm2
-rw-r--r--src/Mapbox/Style.elm2
-rw-r--r--src/js/main.js9
7 files changed, 201 insertions, 248 deletions
diff --git a/examples/MapCommands.elm b/examples/MapCommands.elm
index 3eabc69..1730ee1 100644
--- a/examples/MapCommands.elm
+++ b/examples/MapCommands.elm
@@ -1,4 +1,4 @@
-port module MapCommands exposing (id, panBy, panTo, zoomTo, zoomIn, zoomOut, rotateTo, jumpTo, easeTo, flyTo, stop, fitBounds, resize)
+port module MapCommands exposing (easeTo, fitBounds, flyTo, id, jumpTo, panBy, panTo, resize, rotateTo, stop, zoomIn, zoomOut, zoomTo)
{-| Tell your map to do something! Most of these Commands tell your map to (with or without animation) to show a different location. You can use the options from `Mapbox.Cmd.Option` to configure these.
@@ -16,9 +16,9 @@ port module MapCommands exposing (id, panBy, panTo, zoomTo, zoomIn, zoomOut, rot
-}
-import Mapbox.Cmd.Template as Template exposing (Option, Supported)
import Json.Encode as Encode exposing (Value)
import LngLat exposing (LngLat)
+import Mapbox.Cmd.Template as Template exposing (Option, Supported)
port elmMapboxOutgoing : Value -> Cmd msg
@@ -228,57 +228,3 @@ flyTo =
stop : Cmd msg
stop =
Template.stop elmMapboxOutgoing id
-
-
-{-| Sets the map's [RTL text plugin](https://www.mapbox.com/mapbox-gl-js/plugins/#mapbox-gl-rtl-text). Necessary for supporting languages like Arabic and Hebrew that are written right-to-left. Takes a URL pointing to the Mapbox RTL text plugin source.
--}
-setRTLTextPlugin : String -> Cmd msg
-setRTLTextPlugin =
- Template.setRTLTextPlugin elmMapboxOutgoing id
-
-
-
--- incoming
-
-
-{-| Responds with the map's geographical bounds. Takes a numerical ID that allows you to associate the question with the answer.
--}
-getBounds : Int -> Cmd msg
-getBounds =
- Template.getBounds elmMapboxOutgoing id
-
-
-{-| Returns an array of GeoJSON Feature objects representing visible features that satisfy the query parameters. Takes a numerical ID that allows you to associate the question with the answer.
-
-The response: The properties value of each returned feature object contains the properties of its source feature. For GeoJSON sources, only string and numeric property values are supported (i.e. null, Array, and Object values are not supported).
-
-Each feature includes a top-level layer property whose value is an object representing the style layer to which the feature belongs. Layout and paint properties in this object contain values which are fully evaluated for the given zoom level and feature.
-
-Features from layers whose visibility property is "none", or from layers whose zoom range excludes the current zoom level are not included. Symbol features that have been hidden due to text or icon collision are not included. Features from all other layers are included, including features that may have no visible contribution to the rendered result; for example, because the layer's opacity or color alpha component is set to 0.
-
-The topmost rendered feature appears first in the returned array, and subsequent features are sorted by descending z-order. Features that are rendered multiple times (due to wrapping across the antimeridian at low zoom levels) are returned only once (though subject to the following caveat).
-
-Because features come from tiled vector data or GeoJSON data that is converted to tiles internally, feature geometries may be split or duplicated across tile boundaries and, as a result, features may appear multiple times in query results. For example, suppose there is a highway running through the bounding rectangle of a query. The results of the query will be those parts of the highway that lie within the map tiles covering the bounding rectangle, even if the highway extends into other tiles, and the portion of the highway within each map tile will be returned as a separate feature. Similarly, a point feature near a tile boundary may appear in multiple tiles due to tile buffering.
-
--}
-queryRenderedFeatures : Int -> List (Option { layers : Supported, filter : Supported, query : Supported }) -> Cmd msg
-queryRenderedFeatures =
- Template.queryRenderedFeatures elmMapboxOutgoing id
-
-
-{-| A response to the queries. See the relevant methods for more information.
--}
-type Response
- = GetBounds Int ( LngLat, LngLat )
- | QueryRenderedFeatures Int (List Value)
- | Error String
-
-
-port elmMapboxIncoming : (Value -> msg) -> Sub msg
-
-
-{-| Receive results from the queries
--}
-queryResults : (Response -> msg) -> Sub msg
-queryResults =
- Template.queryResults elmMapboxIncoming GetBounds QueryRenderedFeatures Error
diff --git a/src/Mapbox/Element.elm b/src/Mapbox/Element.elm
index f7382ca..14b6873 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, renderWorldCopies, EventData, TouchEvent, eventFeaturesFilter, eventFeaturesLayers, onMouseDown, onMouseUp, onMouseOver, onMouseMove, onClick, onDblClick, onMouseOut, onContextMenu, onZoom, onZoomStart, onZoomEnd, onRotate, onRotateStart, onRotateEnd, onTouchEnd, onTouchMove, onTouchCancel)
+module Mapbox.Element exposing (EventData, MapboxAttr, TouchEvent, css, eventFeaturesFilter, eventFeaturesLayers, id, map, maxBounds, maxZoom, minZoom, onClick, onContextMenu, onDblClick, onMouseDown, onMouseMove, onMouseOut, onMouseOver, onMouseUp, onRotate, onRotateEnd, onRotateStart, onTouchCancel, onTouchEnd, onTouchMove, onZoom, onZoomEnd, onZoomStart, renderWorldCopies, token)
{-| This library wraps a Custom Element that actually renders a map.
@@ -25,8 +25,8 @@ import Json.Decode as Decode exposing (Decoder, Value)
import Json.Encode as Encode
import LngLat exposing (LngLat)
import Mapbox.Expression exposing (DataExpression, Expression)
-import Mapbox.Style exposing (Style)
import Mapbox.Helpers exposing (encodePair)
+import Mapbox.Style exposing (Style)
{-| This is the type that all attributes have.
@@ -51,15 +51,15 @@ map attrs style =
(Mapbox.Style.encode style
|> property "mapboxStyle"
)
- :: (List.map (\(MapboxAttr attr) -> attr) attrs)
+ :: List.map (\(MapboxAttr attr) -> attr) attrs
in
- node "elm-mapbox-map" props []
+ node "elm-mapbox-map" props []
{-| This is literally:
<link
- href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.46.0/mapbox-gl.css'
+ href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.47.0/mapbox-gl.css'
rel='stylesheet' />
You can include the required styles yourself if it fits better with the way you deploy your assets, this is meant as a quick way to get started.
@@ -67,7 +67,7 @@ You can include the required styles yourself if it fits better with the way you
-}
css : Html msg
css =
- node "link" [ attribute "href" "https://api.tiles.mapbox.com/mapbox-gl-js/v0.46.0/mapbox-gl.css", attribute "rel" "stylesheet" ] []
+ node "link" [ attribute "href" "https://api.tiles.mapbox.com/mapbox-gl-js/v0.47.0/mapbox-gl.css", attribute "rel" "stylesheet" ] []
{-| The minimum zoom level of the map (0-24).
@@ -398,4 +398,4 @@ controlledMap { center, zoom, bearing, pitch } attrs style =
:: property "pitch" (Encode.float pitch)
:: List.map (\(MapboxAttr attr) -> attr) attrs
in
- node "elm-mapbox-map" props []
+ node "elm-mapbox-map" props []
diff --git a/src/Mapbox/Expression.elm b/src/Mapbox/Expression.elm
index 31c53c7..d800188 100644
--- a/src/Mapbox/Expression.elm
+++ b/src/Mapbox/Expression.elm
@@ -1,150 +1,150 @@
module Mapbox.Expression
exposing
- ( Expression
- , DataExpression
+ ( Anchor(..)
+ , AnchorAuto
, CameraExpression
- , encode
+ , Collator
, Color
+ , DataExpression
+ , Expression
+ , Interpolation(..)
+ , LineCap
+ , LineJoin
, Object
- , Collator
- , defaultCollator
- , true
- , false
- , bool
- , int
- , float
- , str
- , rgba
- , floats
- , strings
- , object
- , collator
+ , Position
+ , RasterResampling
+ , SymbolPlacement
+ , TextFit
+ , TextJustify
+ , TextTransform
+ , abs
+ , acos
+ , all
+ , anchorAutoAuto
+ , anchorAutoMap
+ , anchorAutoViewport
+ , anchorMap
+ , anchorViewport
+ , any
+ , append
+ , asin
, assertArray
- , assertArrayOfStrings
- , assertArrayOfFloats
, assertArrayOfBools
+ , assertArrayOfFloats
+ , assertArrayOfStrings
, assertBool
, assertFloat
, assertObject
, assertString
- , toBool
- , toColor
- , toFloat
- , toString
- , typeof
, at
- , get
- , has
+ , atan
+ , bool
+ , ceil
+ , coalesce
+ , collator
+ , conditionally
+ , cos
, count
- , length
+ , defaultCollator
+ , divideBy
+ , downcase
+ , e
+ , encode
+ , false
, featureState
+ , float
+ , floats
+ , floor
, geometryType
- , id
- , properties
+ , get
, getProperty
- , hasProperty
- , isEqual
- , notEqual
- , lessThan
- , lessThanOrEqual
, greaterThan
, greaterThanOrEqual
- , isEqualWithCollator
- , notEqualWithCollator
- , lessThanWithCollator
- , lessThanOrEqualWithCollator
- , greaterThanWithCollator
, greaterThanOrEqualWithCollator
- , not
- , all
- , any
+ , greaterThanWithCollator
+ , has
+ , hasProperty
+ , heatmapDensity
+ , id
, ifElse
- , conditionally
- , matchesStr
- , matchesFloat
- , coalesce
+ , int
, interpolate
- , Interpolation(..)
- , step
- , append
- , downcase
- , upcase
+ , isEqual
+ , isEqualWithCollator
, isSupportedScript
- , resolvedLocale
- , makeRGBColor
- , makeRGBAColor
- , rgbaChannels
- , minus
- , multiply
- , divideBy
- , modBy
- , plus
- , raiseBy
- , sqrt
- , abs
- , ceil
- , floor
- , round
- , cos
- , sin
- , tan
- , acos
- , asin
- , atan
- , e
- , pi
+ , length
+ , lessThan
+ , lessThanOrEqual
+ , lessThanOrEqualWithCollator
+ , lessThanWithCollator
+ , lineCapButt
+ , lineCapRound
+ , lineCapSquare
+ , lineJoinBevel
+ , lineJoinMiter
+ , lineJoinRound
+ , lineProgress
, ln
, ln2
, log10
, log2
- , zoom
- , heatmapDensity
- , lineProgress
- , Anchor(..)
- , anchorMap
- , anchorViewport
- , AnchorAuto
- , anchorAutoMap
- , anchorAutoViewport
- , anchorAutoAuto
- , Position
+ , makeRGBAColor
+ , makeRGBColor
+ , matchesFloat
+ , matchesStr
+ , minus
+ , modBy
+ , multiply
+ , not
+ , notEqual
+ , notEqualWithCollator
+ , object
+ , pi
+ , plus
+ , positionBottom
+ , positionBottomLeft
+ , positionBottomRight
, positionCenter
, positionLeft
, positionRight
, positionTop
- , positionBottom
, positionTopLeft
, positionTopRight
- , positionBottomLeft
- , positionBottomRight
- , TextFit
- , textFitNone
- , textFitWidth
- , textFitHeight
- , textFitBoth
- , LineCap
- , lineCapButt
- , lineCapRound
- , lineCapSquare
- , LineJoin
- , lineJoinBevel
- , lineJoinRound
- , lineJoinMiter
- , SymbolPlacement
- , symbolPlacementPoint
+ , properties
+ , raiseBy
+ , rasterResamplingLinear
+ , rasterResamplingNearest
+ , resolvedLocale
+ , rgba
+ , rgbaChannels
+ , round
+ , sin
+ , sqrt
+ , step
+ , str
+ , strings
, symbolPlacementLine
, symbolPlacementLineCenter
- , TextJustify
- , textJustifyLeft
+ , symbolPlacementPoint
+ , tan
+ , textFitBoth
+ , textFitHeight
+ , textFitNone
+ , textFitWidth
, textJustifyCenter
+ , textJustifyLeft
, textJustifyRight
- , TextTransform
+ , textTransformLowercase
, textTransformNone
, textTransformUppercase
- , textTransformLowercase
- , RasterResampling
- , rasterResamplingLinear
- , rasterResamplingNearest
+ , toBool
+ , toColor
+ , toFloat
+ , toString
+ , true
+ , typeof
+ , upcase
+ , zoom
)
{-| Expressions form a little language that can be used to compute values for various layer properties.
@@ -779,6 +779,12 @@ assertBool =
call1 "boolean"
+{-| -}
+assertBoolWithFalback : Bool -> Expression exprType any -> Expression exprType Bool
+assertBoolWithFalback fallback value =
+ call2 "boolean" value (bool fallback)
+
+
-- assertAtLeastOneBool : List (Expression exprType any) -> Expression exprType Bool
-- assertAtLeastOneBool =
@@ -1099,7 +1105,7 @@ matchesStr options (Expression default) (Expression input) =
properOptions =
List.concatMap (\( label, Expression output ) -> [ Json.Encode.string label, output ]) options
in
- call "match" (input :: properOptions ++ [ default ])
+ call "match" (input :: properOptions ++ [ default ])
{-| Selects the output whose label value matches the input value, or the fallback value if no match is found.
@@ -1119,7 +1125,7 @@ matchesFloat options (Expression default) (Expression input) =
properOptions =
List.concatMap (\( label, Expression output ) -> [ Json.Encode.float label, output ]) options
in
- call "match" (input :: properOptions ++ [ default ])
+ call "match" (input :: properOptions ++ [ default ])
{-| Interpolation types:
diff --git a/src/Mapbox/Layer.elm b/src/Mapbox/Layer.elm
index 20e7af5..ce0fa67 100644
--- a/src/Mapbox/Layer.elm
+++ b/src/Mapbox/Layer.elm
@@ -1,55 +1,22 @@
module Mapbox.Layer
exposing
- ( Layer
- , SourceId
- , Background
- , Fill
- , Symbol
- , Line
- , Raster
+ ( Background
, Circle
+ , Fill
, FillExtrusion
, Heatmap
, Hillshade
+ , Layer
, LayerAttr
- , encode
+ , Line
+ , Raster
+ , SourceId
+ , Symbol
, background
- , fill
- , symbol
- , line
- , raster
+ , backgroundColor
+ , backgroundOpacity
+ , backgroundPattern
, circle
- , fillExtrusion
- , heatmap
- , hillshade
- , metadata
- , sourceLayer
- , minzoom
- , maxzoom
- , filter
- , visible
- , 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
@@ -61,11 +28,11 @@ module Mapbox.Layer
, circleStrokeWidth
, circleTranslate
, circleTranslateAnchor
- , heatmapColor
- , heatmapIntensity
- , heatmapOpacity
- , heatmapRadius
- , heatmapWeight
+ , encode
+ , fill
+ , fillAntialias
+ , fillColor
+ , fillExtrusion
, fillExtrusionBase
, fillExtrusionColor
, fillExtrusionHeight
@@ -73,6 +40,25 @@ module Mapbox.Layer
, fillExtrusionPattern
, fillExtrusionTranslate
, fillExtrusionTranslateAnchor
+ , fillOpacity
+ , fillOutlineColor
+ , fillPattern
+ , fillTranslate
+ , fillTranslateAnchor
+ , filter
+ , heatmap
+ , heatmapColor
+ , heatmapIntensity
+ , heatmapOpacity
+ , heatmapRadius
+ , heatmapWeight
+ , hillshade
+ , hillshadeAccentColor
+ , hillshadeExaggeration
+ , hillshadeHighlightColor
+ , hillshadeIlluminationAnchor
+ , hillshadeIlluminationDirection
+ , hillshadeShadowColor
, iconAllowOverlap
, iconAnchor
, iconColor
@@ -94,6 +80,36 @@ module Mapbox.Layer
, iconTextFitPadding
, iconTranslate
, iconTranslateAnchor
+ , line
+ , lineBlur
+ , lineCap
+ , lineColor
+ , lineDasharray
+ , lineGapWidth
+ , lineGradient
+ , lineJoin
+ , lineMiterLimit
+ , lineOffset
+ , lineOpacity
+ , linePattern
+ , lineRoundLimit
+ , lineTranslate
+ , lineTranslateAnchor
+ , lineWidth
+ , maxzoom
+ , metadata
+ , minzoom
+ , raster
+ , rasterBrightnessMax
+ , rasterBrightnessMin
+ , rasterContrast
+ , rasterFadeDuration
+ , rasterHueRotate
+ , rasterOpacity
+ , rasterResampling
+ , rasterSaturation
+ , sourceLayer
+ , symbol
, symbolAvoidEdges
, symbolPlacement
, symbolSpacing
@@ -123,30 +139,14 @@ module Mapbox.Layer
, textTransform
, textTranslate
, textTranslateAnchor
- , rasterBrightnessMax
- , rasterBrightnessMin
- , rasterContrast
- , rasterResampling
- , rasterFadeDuration
- , rasterHueRotate
- , rasterOpacity
- , rasterSaturation
- , hillshadeAccentColor
- , hillshadeExaggeration
- , hillshadeHighlightColor
- , hillshadeIlluminationAnchor
- , hillshadeIlluminationDirection
- , hillshadeShadowColor
- , backgroundColor
- , backgroundOpacity
- , backgroundPattern
+ , visible
)
{-| Layers specify what is actually rendered on the map and are rendered in order.
Except for layers of the background type, each layer needs to refer to a source. Layers take the data that they get from a source, optionally filter features, and then define how those features are styled.
-There are two kinds of properties: *Layout* and *Paint* properties.
+There are two kinds of properties: _Layout_ and _Paint_ properties.
Layout properties are applied early in the rendering process and define how data for that layer is passed to the GPU. Changes to a layout property require an asynchronous "layout" step.
@@ -218,7 +218,7 @@ Paint properties are applied later in the rendering process. Changes to a paint
import Array exposing (Array)
import Json.Encode as Encode exposing (Value)
-import Mapbox.Expression as Expression exposing (Anchor, AnchorAuto, CameraExpression, Color, DataExpression, Expression, LineCap, LineJoin, Position, SymbolPlacement, TextFit, TextJustify, TextTransform, RasterResampling)
+import Mapbox.Expression as Expression exposing (Anchor, AnchorAuto, CameraExpression, Color, DataExpression, Expression, LineCap, LineJoin, Position, RasterResampling, SymbolPlacement, TextFit, TextJustify, TextTransform)
{-| Represents a layer.
@@ -313,7 +313,7 @@ encodeAttrs attrs =
{ top = [], layout = [], paint = [] }
attrs
in
- ( "layout", Encode.object layout ) :: ( "paint", Encode.object paint ) :: top
+ ( "layout", Encode.object layout ) :: ( "paint", Encode.object paint ) :: top
{-| The background color or pattern of the map.
diff --git a/src/Mapbox/Source.elm b/src/Mapbox/Source.elm
index 7677df8..5cc571d 100644
--- a/src/Mapbox/Source.elm
+++ b/src/Mapbox/Source.elm
@@ -1,4 +1,4 @@
-module Mapbox.Source exposing (Source, SourceOption, raster, tileSize, rasterFromUrl, RasterSource, scheme, Scheme(..), rasterDEMMapbox, rasterDEMTerrarium, geoJSONFromUrl, geoJSONFromValue, GeoJSONSource, buffer, tolerance, cluster, clusterRadius, lineMetrics, Coords, image, video, staticCanvas, animatedCanvas, bounds, minzoom, maxzoom, attribution, encode, getId, Id, Url, vector, vectorFromUrl, VectorSource)
+module Mapbox.Source exposing (Coords, GeoJSONSource, Id, RasterSource, Scheme(..), Source, SourceOption, Url, VectorSource, animatedCanvas, attribution, bounds, buffer, cluster, clusterRadius, encode, geoJSONFromUrl, geoJSONFromValue, getId, image, lineMetrics, maxzoom, minzoom, raster, rasterDEMMapbox, rasterDEMTerrarium, rasterFromUrl, scheme, staticCanvas, tileSize, tolerance, vector, vectorFromUrl, video)
{-|
diff --git a/src/Mapbox/Style.elm b/src/Mapbox/Style.elm
index 1793067..500cf47 100644
--- a/src/Mapbox/Style.elm
+++ b/src/Mapbox/Style.elm
@@ -1,4 +1,4 @@
-module Mapbox.Style exposing (Style(..), StyleDef, encode, Light, defaultLight, Transition, defaultTransition, MiscAttr, sprite, glyphs, name, defaultCenter, defaultZoomLevel, defaultBearing, defaultPitch, metadata, streets, outdoors, light, dark, satellite, satelliteStreets)
+module Mapbox.Style exposing (Light, MiscAttr, Style(..), StyleDef, Transition, dark, defaultBearing, defaultCenter, defaultLight, defaultPitch, defaultTransition, defaultZoomLevel, encode, glyphs, light, metadata, name, outdoors, satellite, satelliteStreets, sprite, streets)
{-| 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.
diff --git a/src/js/main.js b/src/js/main.js
index 255396e..eff72ed 100644
--- a/src/js/main.js
+++ b/src/js/main.js
@@ -108,6 +108,7 @@ function wrapElmApplication(elmApp, settings = {}) {
return this._featureState;
}
set featureState(value) {
+
// TODO: Clean this up
function makeId({id, source, sourceLayer}) {
return `${id}::${source}::${sourceLayer}`;
@@ -171,7 +172,7 @@ function wrapElmApplication(elmApp, settings = {}) {
) {
wrapped = e => {
e.features = this._map.queryRenderedFeatures(
- [e.lngLat.lng, e.lngLat.lat],
+ e.point,
{
layers: this.eventFeaturesLayers,
filter: this.eventFeaturesFilter
@@ -182,14 +183,14 @@ function wrapElmApplication(elmApp, settings = {}) {
} else if (["touchend", "touchmove", "touchcancel"].includes(type)) {
wrapped = e => {
e.features = this._map.queryRenderedFeatures(
- [e.lngLat.lng, e.lngLat.lat],
+ [e.point],
{
layers: this.eventFeaturesLayers,
filter: this.eventFeaturesFilter
}
);
- e.perPointFeatures = e.lngLats.map(({ lng, lat }) =>
- this._map.queryRenderedFeatures([lng, lat], {
+ e.perPointFeatures = e.points.map(point =>
+ this._map.queryRenderedFeatures(point, {
layers: this.eventFeaturesLayers,
filter: this.eventFeaturesFilter
})