andre-dietrich/elm-mapbox/1.0.0

NOTE: the latest version is 2.0.0

Mapbox.Source

Sources

type Source

Sources supply data to be shown on the map. Adding a source won't immediately make data appear on the map because sources don't contain styling details like color or width. Layers refer to a source and give it a visual representation. This makes it possible to style the same source in different ways, like differentiating between types of roads in a highways layer.

type SourceOption sourceType

Some sources can take options.

type alias Id =
String

Every layer is identified by an id.

type alias Url =
String

Represents a URL. For tiles hosted by Mapbox, the "url" value should be of the form mapbox://mapid.

decode : Decoder (List Source)

Vector

vector : Id -> List Url -> List (SourceOption VectorSource) -> Source

A vector tile source. Tiles must be in Mapbox Vector Tile format. All geometric coordinates in vector tiles must be between -1 * extent and (extent * 2) - 1 inclusive. All layers that use a vector source must specify a sourceLayer value.

This takes an array of one or more tile source URLs, as in the TileJSON spec.

vectorFromUrl : Id -> Url -> Source

A vector tile source. Tiles must be in Mapbox Vector Tile format. All geometric coordinates in vector tiles must be between -1 * extent and (extent * 2) - 1 inclusive. All layers that use a vector source must specify a sourceLayer value.

The first argument is the layers id, the second is a url to a TileJSON specification that configures the source.

Marks attributes that are only applicable to vector sources

Raster

raster : Id -> List Url -> List (SourceOption RasterSource) -> Source

A raster tile source. Takes a list of one or more tile source URLs, as in the TileJSON spec.

The minimum visual size to display tiles for this layer.

rasterFromUrl : Id -> Url -> Source

A raster tile source configured from a TileJSON spec.

Marks attributes that are only applicable to raster sources

Raster DEM

A raster DEM source in the Terarrium format.

GeoJSON

A remote GeoJSON source.

A GeoJSON source from some local data.

Marks attributes that are only applicable to GeoJSON sources

Size of the tile buffer on each side. A value of 0 produces no buffer. A value of 512 produces a buffer as wide as the tile itself. Larger values produce fewer rendering artifacts near tile edges and slower performance. Defaults to 128.

Douglas-Peucker simplification tolerance (higher means simpler geometries and faster performance). Defaults to 0.375.

If the data is a collection of point features, setting this clusters the points by radius into groups.

Cluster groups become new Point features in the source with additional properties:

  • cluster Is True if the point is a cluster
  • cluster_id A unqiue id for the cluster.
  • point_count Number of original points grouped into this cluster
  • point_count_abbreviated An abbreviated point count

Radius of each cluster if clustering is enabled. A value of 512 indicates a radius equal to the width of a tile.

List
( String
, Expression DataExpression a
-> Expression DataExpression b
-> Expression DataExpression b
, Expression DataExpression a
)

When clustering, you may want to aggregate values from the points included in the cluster. This function allows you to associate a name that will be the property name with a fold that computes the aggregation. For example:

clusterProperties
    [ ( "sum", E.plus, E.getProperty (str "scalerank") )
    , ( "max", \point aggregate -> E.max aggregate point, E.getProperty (str "scalerank") )
    ]

Would produce clusters with two additional properties: sum and max, which you could then further use in data driven styling.

Whether to calculate line distance metrics. This is required for line layers that specify lineGradient values.

When set, the feature.id property will be auto assigned based on its index in the features array, over-writing any previous values.

Image, Video & Canvas

type alias Coords =
{ topLeft : LngLat
, topRight : LngLat
, bottomRight : LngLat
, bottomLeft : LngLat
}

(longitude, latitude) pairs for the corners. You can use the type alias constructor in clockwise order: top left, top right, bottom right, bottom left.

image : Id -> Url -> Coords -> Source

An image source

video : Id -> List Url -> Coords -> Source

A video source. For each URL in the list, a video element source will be created, in order to support same media in multiple formats supported by different browsers.

staticCanvas : Id -> String -> Coords -> Source

A data source containing the contents of an HTML canvas. The second argument must be the DOM ID of the canvas element. This method is only appropriate with a static Canvas (i.e. one that doesn't change), as it will be cached to improve performance.

animatedCanvas : Id -> String -> Coords -> Source

A data source containing the contents of an HTML canvas. The second argument must be the DOM ID of the canvas element. This method is only appropriate with an animated Canvas (i.e. one that changes over time).

Tiled sources

Tiled sources can also take the following attributes:

bounds : LngLat -> LngLat -> SourceOption any

The longitude and latitude of the southwest and northeast corners of the source's bounding box. When this property is included in a source, no tiles outside of the given bounds are requested by Mapbox GL.

minzoom : Float -> SourceOption any

Minimum zoom level for which tiles are available, as in the TileJSON spec.

maxzoom : Float -> SourceOption any

Maximum zoom level for which tiles are available, as in the TileJSON spec. Data from tiles at the maxzoom are used when displaying the map at higher zoom levels.

attribution : String -> SourceOption any

Contains an attribution to be displayed when the map is shown to a user.

Influences the y direction of the tile coordinates. The global-mercator (aka Spherical Mercator) profile is assumed.

type Scheme
= XYZ
| TMS

XYZ: Slippy map tilenames scheme.

TMS: OSGeo spec scheme.

Working with sources

encode : Source -> Value
getId : Source -> String