From 8106ecee77366b7c6a6601be897fe41f533436a1 Mon Sep 17 00:00:00 2001 From: James Diacono Date: Wed, 17 Oct 2018 23:47:05 +1100 Subject: [PATCH 1/2] Ensure attributions appear after switching layers --- index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/index.js b/index.js index bab7003..45a1b6f 100644 --- a/index.js +++ b/index.js @@ -177,6 +177,7 @@ L.TileLayer.Bing = L.TileLayer.extend({ this._attributions.forEach(function (attribution) { map.attributionControl.removeAttribution(attribution) }) + this._attributions = [] L.TileLayer.prototype.onRemove.call(this, map) }, From 0ab92ba5d1778c077032ee3da3ed6ced3354ba3c Mon Sep 17 00:00:00 2001 From: James Diacono Date: Wed, 17 Oct 2018 23:48:24 +1100 Subject: [PATCH 2/2] Handle layer change during fetch --- index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/index.js b/index.js index 45a1b6f..a44b5bb 100644 --- a/index.js +++ b/index.js @@ -232,6 +232,9 @@ L.TileLayer.Bing = L.TileLayer.extend({ var zoom = map.getZoom() var bbox = toBingBBox(map.getBounds().toBBoxString()) this._fetch.then(function () { + // Layer has been removed during fetch + if (!this._map) return + var newAttributions = this._getAttributions(bbox, zoom) var prevAttributions = this._attributions // Add any new provider attributions in the current area to the attribution control