Skip to content
Wrapper for Mapbox Gl JS library that gives nice Promise-based API to asynchronous map functions
Branch: master
Clone or download
Latest commit 7242908 Dec 8, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dist New build Dec 1, 2018
src New build Dec 1, 2018
.browserslistrc Updated webpack configuration Nov 5, 2018
.gitignore Map methods updated Nov 10, 2018
LICENSE Initial commit Nov 4, 2018
README.md README updated Dec 8, 2018
babel.config.js Updated webpack configuration Nov 5, 2018
package-lock.json 0.4.0 Dec 8, 2018
package.json 0.4.0 Dec 8, 2018
tsconfig.json Added tslint configuration Nov 5, 2018
tslint.json Added tslint configuration Nov 5, 2018
webpack.config.js New build Dec 1, 2018

README.md

map-promisified

Wrapper for Mapbox Gl JS library that gives nice Promise-based API to asynchronous map functions

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
You can’t perform that action at this time.