1.0.9 • Published 2 months ago

nuxt-mapbox-gl v1.0.9

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

nuxt-mapbox-gl

Version

Nuxt module that adds required mapbox-gl options and injects mapbox-gl into $root & context (accessible with $this.mapbox)

Install

Use yarn to install the module

yarn add nuxt-mapbox-gl

Or use npm to install the module

npm install nuxt-mapbox-gl

Usage

nuxt.config.js

{
  modules: ['nuxt-mapbox-gl'],
  mapbox: {
    accessToken: process.env.MAPBOX_ACCESS_TOKEN
  }
}

index.vue

<template>
  <div id="map"></div>
</template>

<script>
export default {
  mounted() {
    this.loadMap()
  },
  methods: {
    loadMap() {
      this.map = new this.$mapbox.Map({
        container: 'map',
        style: 'mapbox://styles/mapbox/streets-v11',
        center: [0, 0],
        zoom: 0.6,
        projection: 'naturalEarth' // starting projection
      })
    }
  }
}
</script>
<style>
body {
  margin: 0;
  padding: 0;
}
#map {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 100%;
}
</style>
1.0.9

2 months ago

1.0.8

6 months ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago