Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add back "Powered by Esri" attribution for vectorBasemapLayer when using an item ID #229

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion spec/VectorBasemapLayerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ describe('VectorBasemapLayer', function () {
};

layer._setupAttribution();
const expectedAttributionValue = '<span class="esri-dynamic-attribution">@ my attribution, @ my copyright text</span>';
const expectedAttributionValue = '<span class="esri-dynamic-attribution">Powered by <a href="https://www.esri.com">Esri</a> | @ my attribution, @ my copyright text</span>';
expect(attributionValue).to.be.equal(expectedAttributionValue);
});
});
Expand Down
10 changes: 6 additions & 4 deletions src/VectorBasemapLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { Util } from 'esri-leaflet';
import { getBasemapStyleUrl, getAttributionData, getBasemapStyleV2Url } from './Util';
import { VectorTileLayer } from './VectorTileLayer';

const POWERED_BY_ESRI_ATTRIBUTION_STRING = 'Powered by <a href="https://www.esri.com">Esri</a>';

export var VectorBasemapLayer = VectorTileLayer.extend({
/**
* Populates "this.options" to be used in the rest of the module.
Expand Down Expand Up @@ -69,9 +71,6 @@ export var VectorBasemapLayer = VectorTileLayer.extend({
},

_setupAttribution: function () {
// Set attribution
Util.setEsriAttribution(this._map);

if (this.options.key.length === 32) {
// this is an itemId
const sources = this._maplibreGL.getMaplibreMap().style.stylesheet.sources;
Expand All @@ -83,7 +82,10 @@ export var VectorBasemapLayer = VectorTileLayer.extend({
}
});

this._map.attributionControl.addAttribution(`<span class="esri-dynamic-attribution">${allAttributions.join(', ')}</span>`);
// In the case of an enum, since the attribution is dynamic, Esri Leaflet
// will add the "Powered by Esri" string. But in this case we are not
// dynamic so we must add it ourselves.
this._map.attributionControl.addAttribution(`<span class="esri-dynamic-attribution">${POWERED_BY_ESRI_ATTRIBUTION_STRING} | ${allAttributions.join(', ')}</span>`);
} else {
// this is an enum
if (!this.options.attributionUrls) {
Expand Down
Loading