@vinayakkulkarni/map-promisified
v0.0.3
Published
Wrapper for Mapbox GL JS library that gives nice Promise-based API for asynchronous map functions
Downloads
5
Maintainers
Readme
map-promisified 🖖
Features
- Wrapper for Mapbox Gl JS library that gives nice Promise-based API to asynchronous map functions
Table of Contents
Requirements
- mapbox-gl
^1.13.x
Installation
npm install --save map-promisified
npm install --save-dev @vue/composition-api
CDN: UNPKG | jsDelivr (available as window.VOffline
)
Build Setup
# install dependencies
$ npm ci
# package the library
$ npm run build
Usage:
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
Built with
Contributing
- 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
Author
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