Skip to content

Commit

Permalink
Merge pull request #1366 from gr-maps/util-leaflet-prefix-attribution
Browse files Browse the repository at this point in the history
attribution - move "powered by esri" out of the "prefix"
  • Loading branch information
gavinr committed Jul 21, 2023
2 parents 6072ed2 + 20afa44 commit 2b4e9ee
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
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

0 comments on commit 2b4e9ee

Please sign in to comment.