Skip to content

Commit 94017db

Browse files
authored
Merge pull request #3 from gavinr-maps/attribution-powered-by-fixes
Attribution powered by fixes
2 parents 59729d4 + c43ac05 commit 94017db

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/StaticBasemapTileLayer.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
*/
1515
import { TileLayer, setOptions } from 'leaflet';
1616
import { getStaticBasemapTilesUrl, fetchAttribution } from './Util';
17-
import { Util } from 'esri-leaflet';
17+
// import { Util } from 'esri-leaflet';
18+
19+
// In the future, get this from Esri Leaflet Util:
20+
const POWERED_BY_ESRI_ATTRIBUTION_STRING = 'Powered by <a href="https://www.esri.com">Esri</a>';
1821

1922
export var StaticBasemapTileLayer = TileLayer.extend({
2023
initialize: function (style, options) {
@@ -78,14 +81,17 @@ export var StaticBasemapTileLayer = TileLayer.extend({
7881
},
7982
_setupAttribution: function () {
8083
if (!this._map) return;
81-
Util.setEsriAttribution(this._map);
8284
fetchAttribution(this.options.style, this.options.token).then(attribution => {
8385
// Add attribution directly to map
84-
this._map.attributionControl.addAttribution(attribution);
86+
this.currentAttribution = `${POWERED_BY_ESRI_ATTRIBUTION_STRING} | ${attribution}`;
87+
this._map.attributionControl.addAttribution(this.currentAttribution);
8588
});
8689
},
8790
_removeAttribution: function () {
88-
if (Util.removeEsriAttribution) Util.removeEsriAttribution(this._map);
91+
if (this.currentAttribution) {
92+
this._map.attributionControl.removeAttribution(this.currentAttribution);
93+
this.currentAttribution = undefined;
94+
}
8995
},
9096
_initPane: function () {
9197
if (this._map.getPane(this.options.pane)) return;

0 commit comments

Comments
 (0)