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

attribution - move "powered by esri" out of the "prefix" #1366

Merged
merged 1 commit into from
Jul 21, 2023
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
14 changes: 14 additions & 0 deletions spec/Layers/BasemapLayerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,20 @@ describe('L.esri.BasemapLayer', function () {
expect(L.esri.basemapLayer('Topographic')).to.be.instanceof(L.esri.BasemapLayer);
});

it('should not affect the attribution control prefix', function () {
map.attributionControl.setPrefix('aaa');
const layer = L.esri.basemapLayer('Topographic');
layer.addTo(map);
expect(map.attributionControl.options.prefix).to.equal('aaa');
});

it('should handle empty attribution prefix similar to tile layer', function () {
map.attributionControl.setPrefix('');
const layer = L.esri.basemapLayer('Topographic');
layer.addTo(map);
expect(map.attributionControl.options.prefix).to.equal('');
});

// /*
// need to figure out how to wire up the mockAttributions to
// test display when map is panned beyond the dateline
Expand Down
5 changes: 1 addition & 4 deletions src/Util.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
arcgisToGeoJSON as a2g
} from '@terraformer/arcgis';

var BASE_LEAFLET_ATTRIBUTION_STRING = '<a href="http://leafletjs.com" title="A JS library for interactive maps">Leaflet</a>';
var POWERED_BY_ESRI_ATTRIBUTION_STRING = 'Powered by <a href="https://www.esri.com">Esri</a>';

export function geojsonToArcGIS (geojson, idAttr) {
Expand Down Expand Up @@ -217,7 +216,6 @@ export function setEsriAttribution (map) {
map.attributionControl._esriAttributionAddedOnce = true;
}

map.attributionControl.setPrefix(BASE_LEAFLET_ATTRIBUTION_STRING + ' | ' + POWERED_BY_ESRI_ATTRIBUTION_STRING);
DomUtil.addClass(map.attributionControl._container, 'esri-truncated-attribution:hover');
DomUtil.addClass(map.attributionControl._container, 'esri-truncated-attribution');
}
Expand All @@ -233,7 +231,6 @@ export function removeEsriAttribution (map) {

// Only remove the attribution if we're about to remove the LAST esri-leaflet layer (_esriAttributionLayerCount)
if (map.attributionControl._esriAttributionLayerCount && map.attributionControl._esriAttributionLayerCount === 1) {
map.attributionControl.setPrefix(BASE_LEAFLET_ATTRIBUTION_STRING);
DomUtil.removeClass(map.attributionControl._container, 'esri-truncated-attribution:hover');
DomUtil.removeClass(map.attributionControl._container, 'esri-truncated-attribution');
}
Expand Down Expand Up @@ -356,7 +353,7 @@ export function _updateMapAttribution (evt) {
}
}

newAttributions = newAttributions.substr(2);
newAttributions = POWERED_BY_ESRI_ATTRIBUTION_STRING + ' | ' + newAttributions.substr(2);
attributionElement.innerHTML = newAttributions;
attributionElement.style.maxWidth = calcAttributionWidth(map);

Expand Down