From 2b8af3f3cc46aa611efd2c717d3581d197ca84da Mon Sep 17 00:00:00 2001 From: Angelos Orfanakos Date: Wed, 15 Nov 2017 23:49:17 +0200 Subject: [PATCH] Update attribution when adding map if empty This fixes the attributions not being fetched and not showing initially when the map is added to the DOM and the layer is added to the map at a later point (e.g. on a button click). --- index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/index.js b/index.js index cd5a218..ba6bd1c 100644 --- a/index.js +++ b/index.js @@ -152,6 +152,11 @@ L.TileLayer.Bing = L.TileLayer.extend({ onAdd: function (map) { map.on('moveend', this._updateAttribution, this) L.TileLayer.prototype.onAdd.call(this, map) + + if (this._attributions.length === 0) { + this._updateAttribution() + } + this._attributions.forEach(function (attribution) { map.attributionControl.addAttribution(attribution) })