Create a lookup of unique attributions
This commit is contained in:
@@ -157,6 +157,7 @@ ol.control.Attribution.prototype.getSourceAttributions = function(frameState) {
|
|||||||
var attributions = ol.obj.assign({}, frameState.attributions);
|
var attributions = ol.obj.assign({}, frameState.attributions);
|
||||||
/** @type {Object.<string, ol.Attribution>} */
|
/** @type {Object.<string, ol.Attribution>} */
|
||||||
var hiddenAttributions = {};
|
var hiddenAttributions = {};
|
||||||
|
var uniqueAttributions = {};
|
||||||
var projection = /** @type {!ol.proj.Projection} */ (frameState.viewState.projection);
|
var projection = /** @type {!ol.proj.Projection} */ (frameState.viewState.projection);
|
||||||
for (i = 0, ii = layerStatesArray.length; i < ii; i++) {
|
for (i = 0, ii = layerStatesArray.length; i < ii; i++) {
|
||||||
source = layerStatesArray[i].layer.getSource();
|
source = layerStatesArray[i].layer.getSource();
|
||||||
@@ -182,19 +183,13 @@ ol.control.Attribution.prototype.getSourceAttributions = function(frameState) {
|
|||||||
} else {
|
} else {
|
||||||
intersectsTileRange = false;
|
intersectsTileRange = false;
|
||||||
}
|
}
|
||||||
var attributionAlreadyAdded = false;
|
|
||||||
if (intersectsTileRange) {
|
if (intersectsTileRange) {
|
||||||
if (sourceAttributionKey in hiddenAttributions) {
|
if (sourceAttributionKey in hiddenAttributions) {
|
||||||
delete hiddenAttributions[sourceAttributionKey];
|
delete hiddenAttributions[sourceAttributionKey];
|
||||||
}
|
}
|
||||||
for (var existingKey in attributions) {
|
var html = sourceAttribution.getHTML();
|
||||||
if (attributions.hasOwnProperty(existingKey)) {
|
if (!(html in uniqueAttributions)) {
|
||||||
if (attributions[existingKey].getHTML() === sourceAttribution.getHTML()) {
|
uniqueAttributions[html] = true;
|
||||||
attributionAlreadyAdded = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!attributionAlreadyAdded) {
|
|
||||||
attributions[sourceAttributionKey] = sourceAttribution;
|
attributions[sourceAttributionKey] = sourceAttribution;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user