[Vuejs]-Vue Set Data on Mapbox Click

4👍

It’s a contextual binding issue. the this here does not refer to your vue instance but the map instead.

// fat arrow solves this
map.on('click', function(e) => {

})

// aliasing solves this
const self = this
map.on('click', function(e) {

})

// binding solves this
map.on('click', function(e) => {

}.bind(this))

Leave a comment