vue-mapbox icon indicating copy to clipboard operation
vue-mapbox copied to clipboard

@load function makes maps irresponsive

Open jmoidunny opened this issue 6 years ago • 2 comments

<MglMap :accessToken="accessToken" :mapStyle="mapStyle" :hash="true" :attributionControl="false" @load="onMapLoaded" >

onMapLoaded(event){ this.mapbox = event.map }

then when try to do zoom-in zoom-out map get destroyed

jmoidunny avatar Aug 28 '19 10:08 jmoidunny

I encountered a comparable issue: when I drag the viewport, the styles get messed up. When the map is not stored as a Vue data, everything is alright.

I wonder why?

thom4parisot avatar Mar 23 '20 10:03 thom4parisot

If the map is stored in your component's data, then Vue adds a bunch of watchers for reactivity. That breaks the map. You can keep a reference to the map in your component like so:

created() { this.map = null; },

And then set this.map equal to the map you get in your @load handler.

rognstad avatar Apr 02 '20 15:04 rognstad