Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/soal/map-promisified
Wrapper for Mapbox Gl JS library that gives nice Promise-based API to asynchronous map functions
https://github.com/soal/map-promisified
mapbox-gl mapbox-gl-js promise
Last synced: 3 months ago
JSON representation
Wrapper for Mapbox Gl JS library that gives nice Promise-based API to asynchronous map functions
- Host: GitHub
- URL: https://github.com/soal/map-promisified
- Owner: soal
- License: mit
- Created: 2018-11-04T13:52:52.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-07-20T01:22:46.000Z (over 2 years ago)
- Last Synced: 2024-10-17T17:14:51.452Z (3 months ago)
- Topics: mapbox-gl, mapbox-gl-js, promise
- Language: TypeScript
- Size: 110 KB
- Stars: 33
- Watchers: 5
- Forks: 4
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# map-promisified
Wrapper for Mapbox Gl JS library that gives nice Promise-based API to asynchronous map functionsUsage:
```javascript
import promisify from 'map-promisified'
import Mapbox from 'mapbox-gl'const map = new Mapbox.Map({
// … map properties …
})// promisify single method:
const flyToPromisified = promisify(map, 'flyTo')async function flyToPosition () {
const newPosition = await flyToPromisified([10, 20])
console.log(newPosition)
// ⇒ { bearing: 0
// center: Object { lng: …, lat: … },
// pitch: 0,
// zoom: 9
// }
}// promisify all async map methods:
const actions = promisify(map)async function flyToPositionAction () {
const newPosition = await actions.flyTo([10, 20])
console.log(newPosition)
// ⇒ { bearing: 0
// center: Object { lng: …, lat: … },
// pitch: 0,
// zoom: 9
// }
}
```Promisified methods:
* setCenter
* panBy
* panTo
* setZoom
* zoomTo
* zoomIn
* zoomOut
* setBearing
* rotateTo
* resetNorth
* snapToNorth
* setPitch
* fitBounds
* fitScreenCoordinates
* jumpTo
* easeTo
* flyTo