UNPKG

vue-mapbox

Version:

> Combine powers of [Vue.js](https://vuejs.org/) and [Mapbox Gl JS](https://mapbox.com/mapbox-gl-js)

27 lines (25 loc) 776 B
export default { methods: { $_emitSelfEvent(event, data = {}) { this.$_emitMapEvent(event, { control: this.control, ...data }); }, /** Bind events for markers, popups and controls. * MapboxGL JS emits this events on popup or marker object, * so we treat them as 'self' events of these objects */ $_bindSelfEvents(events, emitter) { Object.keys(this.$listeners).forEach(eventName => { if (events.includes(eventName)) { emitter.on(eventName, this.$_emitSelfEvent); } }); }, $_unbindSelfEvents(events, emitter) { if (events.length === 0) return; if (!emitter) return; events.forEach(eventName => { emitter.off(eventName, this.$_emitSelfEvent); }); } } };