ngx-leaflet icon indicating copy to clipboard operation
ngx-leaflet copied to clipboard

Map container is being reused by another instance

Open neverlose-lv opened this issue 1 year ago • 2 comments

  ngOnDestroy(): void {
    if (this.map) {
      this.map.remove();
    }
  }

results me into an error:

Map container is being reused by another instance

neverlose-lv avatar Feb 27 '23 18:02 neverlose-lv

The same thing happens to me and I am not able to solve it

epazs avatar Mar 25 '23 20:03 epazs

Had the same issue... The problem came from my own component ngOnDestroy calling remove() on the map instance. The directive does it already so it's no use and breaks the following test in the leaflet source, since after the 1st remove, this._containerId is undefined :

if (this._containerId !== this._container._leaflet_id) {
  throw new Error('Map container is being reused by another instance');
}

Just get rid of your own this.map.remove() in your ngOnDestroy.

vvandens avatar Jul 05 '23 11:07 vvandens