jackhp95/elm-mapbox/1.0.1

NOTE: the latest version is 2.0.0

Rerouted (fork, verified). The original repository is gone. This copy comes from a fork that still has the tag. The Lamdera package server serves a copy recovered from https://github.com/elm-review-bot/elm-mapbox (a fork).

What we checked: Rebuilt with git archive from commit be2348dcc8be of https://github.com/elm-review-bot/elm-mapbox (a fork) (zip prefix jackhp95-elm-mapbox-be2348d/, America/Los_Angeles times): the zip is byte-identical to the one package.elm-lang.org recorded, SHA-1 3c49f17d1449731e8179a584fcc95b89360b658c.

The Lamdera compiler uses this copy and prints a one-line notice saying so. elm itself fails to download this version.

Details · package.elm-lang.org's zip: https://github.com/jackhp95/elm-mapbox/zipball/1.0.1/

Maps

Functions for creating a maps program and maniuplating the maps model.

Showing a map

You can use the functions below to display a map.

import Maps
import Html exposing (program)


main = program
	{ init = (Maps.defaultModel, Cmd.none)
	, subscriptions = Maps.subscriptions
	, update = Maps.update
	, view = Maps.view
	}
defaultModel : Model msg

The default model is a map zoomed into Sydney, Australia with no markers.

subscriptions : Model msg -> Sub (Msg msg)
update : Msg msg -> Model msg -> ( Model msg, Cmd (Msg msg) )
view : Model msg -> Html (Msg msg)
mapView : (Msg msg -> msg) -> Html (Msg msg) -> Html msg

Transforms the Maps HTML view into an arbitrary HTML view. Requires a function that can transform Maps.Msgs into msgs.

import Html
import Html.Event exposing (onClick)
import Maps

type MyMsg = Click | MapsMsg Maps.Msg

...

view msg model =
  Html.div
    []
    [ Maps.view model.map |> Maps.mapView MapsMsg
    , Html.button [ onClick Click ] [ Html.text "Click!" ]
    ]

Update Model

updateMap : (Map -> Map) -> Model msg -> Model msg

Change the map inside of a model.

For example, set the width/height of a map and zoom into Seoul, South Korea:

import Maps.Geo
import Maps.Map as Map


let
  seoul = Maps.Geo.latLng 37.532600 127.024612
in
  model
  |> updateMap (Map.setHeight 600)
  |> updateMap (Map.setWidth 1000)
  |> updateMap (Map.viewBounds <| Maps.Geo.centeredBounds 10 seoul)

See Maps.Map for documentation of the Map functions.

updateMarkers : (List (Marker msg) -> List (Marker msg)) -> Model msg -> Model msg

Change the markers inside of the model

For example, add markers for some Sydney attractions and then another marker for the city center:

import Maps.Geo
import Maps.Marker as Marker


let
  attractions =
    List.map (uncurry Maps.Geo.latLng)
      [ (-33.852324, 151.210819)
      , (-33.856872, 151.215239)
      , (-33.870397, 151.208835)
      ]
  sydney = Maps.Geo.latLng -33.865143 151.209900
in
  model
  |> updateMarkers (\markers -> List.map Marker.create attractions ++ markers)
  |> updateMarkers ((::) (Marker.create sydney))

See Maps.Marker for documentation of the Marker functions.

Types

The following types are opaque. Use the functions above to maniuplate and extract information from them.

type alias Msg msg =
Msg msg
type alias Model msg =
Model msg