andre-dietrich / elm-mapbox / Mapbox.Cmd.Template

This module has a bunch of essentially imperative commands for your map.

However, since a published library can't have ports in it, you will need to do some setup. The easiest way to do this is to copy this file into your app. You can see the module docs for that here.


type alias Id =
String

Every command takes the DOM id of the map that it should operate on.


type alias Outgoing msg =
Json.Encode.Value -> Platform.Cmd.Cmd msg

The type of a port that you need to provide for this module to work.


type alias Option support =
Mapbox.Cmd.Internal.Option support

This is exported here to simply for convenience. See Cmd.Option for more docs.

Moving the map around

panBy : Outgoing msg -> Id -> List (Option { duration : Supported, easing : Supported, offset : Supported, animate : Supported }) -> ( Basics.Int, Basics.Int ) -> Platform.Cmd.Cmd msg

Pans the map by the specified offest.

panTo : Outgoing msg -> Id -> List (Option { duration : Supported, easing : Supported, offset : Supported, animate : Supported }) -> LngLat -> Platform.Cmd.Cmd msg

Pans the map to the specified location, with an animated transition.

zoomTo : Outgoing msg -> Id -> List (Option { duration : Supported, easing : Supported, offset : Supported, animate : Supported }) -> Basics.Float -> Platform.Cmd.Cmd msg

Zooms the map to the specified zoom level, with an animated transition.

zoomIn : Outgoing msg -> Id -> List (Option { duration : Supported, easing : Supported, offset : Supported, animate : Supported }) -> Platform.Cmd.Cmd msg

Increases the map's zoom level by 1.

zoomOut : Outgoing msg -> Id -> List (Option { duration : Supported, easing : Supported, offset : Supported, animate : Supported }) -> Platform.Cmd.Cmd msg

Decreases the map's zoom level by 1.

rotateTo : Outgoing msg -> Id -> List (Option { duration : Supported, easing : Supported, offset : Supported, animate : Supported }) -> Basics.Float -> Platform.Cmd.Cmd msg

Rotates the map to the specified bearing, with an animated transition. The bearing is the compass direction that is "up"; for example, a bearing of 90° orients the map so that east is up.

jumpTo : Outgoing msg -> Id -> List (Option { center : Supported, zoom : Supported, bearing : Supported, pitch : Supported, around : Supported }) -> Platform.Cmd.Cmd msg

Changes any combination of center, zoom, bearing, and pitch, without an animated transition. The map will retain its current values for any details not specified in options.

easeTo : Outgoing msg -> Id -> List (Option { center : Supported, zoom : Supported, bearing : Supported, pitch : Supported, around : Supported, duration : Supported, easing : Supported, offset : Supported, animate : Supported }) -> Platform.Cmd.Cmd msg

Changes any combination of center, zoom, bearing, and pitch, with an animated transition between old and new values. The map will retain its current values for any details not specified in options.

flyTo : Outgoing msg -> Id -> List (Option { center : Supported, zoom : Supported, bearing : Supported, pitch : Supported, around : Supported, duration : Supported, easing : Supported, offset : Supported, animate : Supported, curve : Supported, minZoom : Supported, speed : Supported, screenSpeed : Supported, maxDuration : Supported }) -> Platform.Cmd.Cmd msg

Changes any combination of center, zoom, bearing, and pitch, animating the transition along a curve that evokes flight. The animation seamlessly incorporates zooming and panning to help the user maintain her bearings even after traversing a great distance.

stop : Outgoing msg -> Id -> Platform.Cmd.Cmd msg

Stops any animated transition underway.

Fiting bounds

fitBounds : Outgoing msg -> Id -> List (Option { padding : Supported, easing : Supported, linear : Supported, offset : Supported, maxZoom : Supported }) -> ( LngLat, LngLat ) -> Platform.Cmd.Cmd msg

Pans and zooms the map to contain its visible area within the specified geographical bounds. This function will also reset the map's bearing to 0 if bearing is nonzero.

Other

resize : Outgoing msg -> Id -> Platform.Cmd.Cmd msg

Resizes the map according to the dimensions of its container element.

This command must be sent after the map's container is resized, or when the map is shown after being initially hidden with CSS.