Mapbox GL JS hooks for Vue.
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,
},
});
})
- 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
Made with 💛
Published under MIT License.