1 | # map-promisified
|
2 | Wrapper for Mapbox Gl JS library that gives nice Promise-based API to asynchronous map functions
|
3 |
|
4 | Usage:
|
5 | ```javascript
|
6 | import promisify from 'map-promisified'
|
7 | import Mapbox from 'mapbox-gl'
|
8 |
|
9 | const map = new Mapbox.Map({
|
10 | // … map properties …
|
11 | })
|
12 |
|
13 | // promisify single method:
|
14 | const flyToPromisified = promisify(map, 'flyTo')
|
15 |
|
16 | async function flyToPosition () {
|
17 | const newPosition = await flyToPromisified([10, 20])
|
18 | console.log(newPosition)
|
19 | // ⇒ { bearing: 0
|
20 | // center: Object { lng: …, lat: … },
|
21 | // pitch: 0,
|
22 | // zoom: 9
|
23 | // }
|
24 | }
|
25 |
|
26 | // promisify all async map methods:
|
27 | const actions = promisify(map)
|
28 |
|
29 | async function flyToPositionAction () {
|
30 | const newPosition = await actions.flyTo([10, 20])
|
31 | console.log(newPosition)
|
32 | // ⇒ { bearing: 0
|
33 | // center: Object { lng: …, lat: … },
|
34 | // pitch: 0,
|
35 | // zoom: 9
|
36 | // }
|
37 | }
|
38 | ```
|
39 |
|
40 | Promisified methods:
|
41 | * setCenter
|
42 | * panBy
|
43 | * panTo
|
44 | * setZoom
|
45 | * zoomTo
|
46 | * zoomIn
|
47 | * zoomOut
|
48 | * setBearing
|
49 | * rotateTo
|
50 | * resetNorth
|
51 | * snapToNorth
|
52 | * setPitch
|
53 | * fitBounds
|
54 | * fitScreenCoordinates
|
55 | * jumpTo
|
56 | * easeTo
|
57 | * flyTo
|