- Wrapper for Mapbox Gl JS library that gives nice Promise-based API to asynchronous map functions
- mapbox-gl
^1.13.x
npm install --save map-promisified
npm install --save-dev @vue/composition-api
CDN: UNPKG | jsDelivr (available as window.VOffline
)
# install dependencies
$ npm ci
# package the library
$ npm run build
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
- Fork it ( https://github.com/vinayakkulkarni/map-promisified/fork)
- Create your feature branch (
git checkout -b feat/new-feature
) - Commit your changes (
git commit -Sam 'feat: add feature'
) - Push to the branch (
git push origin feat/new-feature
) - Create a new Pull Request
Note:
- Please contribute using Github Flow
- Commits & PRs will be allowed only if the commit messages & PR titles follow the conventional commit standard, read more about it here
- PS. Ensure your commits are signed. Read why
map-promisified ยฉ Vinayak, Released under the MIT License.
Authored and maintained by Vinayak Kulkarni with help from contributors (list).
vinayakkulkarni.dev ยท GitHub @vinayakkulkarni ยท Twitter @_vinayak_k