Skip to content

Latest commit

 

History

History
103 lines (82 loc) · 2.45 KB

README.md

File metadata and controls

103 lines (82 loc) · 2.45 KB

MapboxUse

npm version npm downloads bundle Codecov License JSDocs

Mapbox GL JS hooks for Vue.

Usage

Install package:

# npm
npm install mapbox-use

# yarn
yarn add mapbox-use

# pnpm
pnpm install mapbox-use

Import:

// ESM
import { useMapbox } from "mapbox-use";

// CommonJS
const { useMapbox } = require("mapbox-use");
const { onLoaded , instance } = useMapbox({
  handlers:{
    tryAddLayer
  }
})

onLoaded(()=>{
  instance.addLayer({
    id: "test",
    type: "fill",
    source: {
      type: "geojson",
      data: {
        type: "Feature",
        geometry: {
          type: "Polygon",
          coordinates: [
            [
              [0, 0],
              [0, 1],
              [1, 1],
              [1, 0],
              [0, 0],
            ],
          ],
        },
      },
    },
    paint: {
      "fill-color": "#f00",
      "fill-opacity": 0.5,
    },
  });
})

Development

  • Clone this repository
  • Install latest LTS version of Node.js
  • Enable Corepack using corepack enable
  • Install dependencies using pnpm install
  • Run interactive tests using pnpm dev

License

Made with 💛

Published under MIT License.