[Vuejs]-Embedding mapbox-gl object in Vue page?

0👍

Have you try on mounted event ?

export default {
    head () {
       ...
    },
    methods: {
        map: function () {

            mapboxgl.accessToken = '<your access token here>'; // optional

            return new mapboxgl.Map({
                container: 'map',
                center: [10.18440, -0],
                zoom: 0.89,
                interactive: false,
                attributionControl:false,

                // set your own style:

                style: 'http://osm-liberty.lukasmartinelli.ch/style.json' // free
                //style: 'mapbox://styles/mapbox/streets-v9'// access token required
            });
        }
    },
    mounted () {
      let map = this.map()
      map.addControl(new mapboxgl.NavigationControl());
    }
}

it works fine ^^

Leave a comment