Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ghivert/elm-mapbox
Mapbox web API easy access.
https://github.com/ghivert/elm-mapbox
elm mapbox
Last synced: 3 months ago
JSON representation
Mapbox web API easy access.
- Host: GitHub
- URL: https://github.com/ghivert/elm-mapbox
- Owner: ghivert
- License: mit
- Created: 2017-07-01T21:13:53.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-07-02T11:09:57.000Z (over 7 years ago)
- Last Synced: 2023-08-08T20:39:23.343Z (over 1 year ago)
- Topics: elm, mapbox
- Language: Elm
- Homepage: http://package.elm-lang.org/packages/ghivert/elm-mapbox/latest
- Size: 9.77 KB
- Stars: 7
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Mapbox
Elm Mapbox aims to provide an easy way to interact with [Mapbox](https://www.mapbox.com/) web API.
Using this package allows to embed a map into a webpage or retrieve tiles informations.## Usage
### Predefined functions
In its more simple form, all you have to do is to use predefined functions with correct parameters, i.e. you Mapbox `access_token` and the correct enpoint.```elm
import Mapbox.Maps.SlippyMap as Mapbox
import Mapbox.Endpoint as EndpointmapboxToken : String
mapboxToken =
"pk.eyJ1IjoiZ2hpdmVydCIsImEiOiJjajRqbzFlcWYwajVzMzNzZTdpZXU3MTRnIn0.wSGB3LCr5OcvPqQ61BqYyg"-- Embed a slippy map into your website and set Options, Hash and Size of the iframe.
embeddedSlippyMap : Html msg
embeddedSlippyMap =
Mapbox.slippyMap Endpoint.streets mapboxToken Nothing Nothing (Mapbox.Size 1000 1000)
````Tiles` and `EditorProject` are returning `Http.Requests GeoJson`. `GeoJson` is a specific Json format representing geographical coordinates and data. It is defined in the package [`mgold/elm-geojson`](https://github.com/mgold/elm-geojson), and you can find additional informations on [geojson.org](http://geojson.org/) or the [RFC7946](https://tools.ietf.org/html/rfc7946) specification.
### Constructing your own requests
You may prefer to construct your own request directly to Mapbox. To do it, use `Mapbox.url` the different arguments are constructing urls based on the Mapbox schema, i.e. `https://api.mapbox.com/{endpoint}{options}{format}?access_token={accessToken}{parameters}`. Obviously, you should preferably use predefined functions, guaranting type checking and providing HTML embedding or HTTP Requests.