Code Monkey home page Code Monkey logo

map-promisified's Introduction

map-promisified ๐Ÿ––

GitHub Workflow Status GitHub Workflow Status GitHub release (latest SemVer) npm npm npm bundle size (version) npm type definitions DeepScan grade Snyk Vulnerabilities for GitHub Repo LGTM Alerts LGTM Grade GitHub contributors

eslint prettier rollup typescript

Features

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

Table of Contents

Requirements

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

  1. Fork it ( https://github.com/vinayakkulkarni/map-promisified/fork)
  2. Create your feature branch (git checkout -b feat/new-feature)
  3. Commit your changes (git commit -Sam 'feat: add feature')
  4. Push to the branch (git push origin feat/new-feature)
  5. Create a new Pull Request

Note:

  1. Please contribute using Github Flow
  2. Commits & PRs will be allowed only if the commit messages & PR titles follow the conventional commit standard, read more about it here
  3. 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

map-promisified's People

Contributors

vinayakkulkarni avatar dependabot[bot] avatar soal avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.