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

Issue when removing vue component with multiple layers

Open helenezspeer opened this issue 5 years ago • 0 comments

Thank you so much for maintaining this repo! We've been using our own fork of vue-mapbox, and we're hoping to contribute our issues and possibly also our solutions.

First: An issue was introduced in vue-mapbox 0.3.2 where removing a vue component that contained multiple mapbox layer components would remove only one of those layer components.

This is caused by a new condition in layerMixin.js, beforeDestroy(): if (this.map) { became if (this.map && this.map.loaded()) {

Once the first layer is removed from the map, this.map.loaded() returns false -- as we would expect, since the style has changed. This causes all subsequent beforeDestroy() calls to allow layers to remain on the map even while their corresponding vue components are removed.

We fixed this by removing the this.map.loaded() condition. However, since the pull request was described "Fixed crash after while destroying the map", I wonder if there are other scenarios that our solution would break? We haven't encountered them ourselves.

I welcome your thoughts.

helenezspeer avatar Nov 25 '20 16:11 helenezspeer