Skip to content

Commit

Permalink
Merge pull request #77 from dmit8914/attr_check
Browse files Browse the repository at this point in the history
check for map.options.attributionControl && map.attributionControl before add attribution
  • Loading branch information
ynunokawa committed May 11, 2018
2 parents 929a3bf + 803dd40 commit ca25992
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/OperationalLayer.js
Expand Up @@ -336,15 +336,17 @@ export function _generateEsriLayer (layer, layers, map, params, paneName) {
token: params.token || null
});

L.esri.request(layer.url, {}, function (err, res) {
if (err) {
console.log(err);
} else {
var maxWidth = (map.getSize().x - 55);
var tiledAttribution = '<span class="esri-attributions" style="line-height:14px; vertical-align: -3px; text-overflow:ellipsis; white-space:nowrap; overflow:hidden; display:inline-block; max-width:' + maxWidth + 'px;">' + res.copyrightText + '</span>';
map.attributionControl.addAttribution(tiledAttribution);
}
});
if (map.options.attributionControl && map.attributionControl) {
L.esri.request(layer.url, {}, function (err, res) {
if (err) {
console.log(err);
} else {
var maxWidth = (map.getSize().x - 55);
var tiledAttribution = '<span class="esri-attributions" style="line-height:14px; vertical-align: -3px; text-overflow:ellipsis; white-space:nowrap; overflow:hidden; display:inline-block; max-width:' + maxWidth + 'px;">' + res.copyrightText + '</span>';
map.attributionControl.addAttribution(tiledAttribution);
}
});
}
}

document.getElementsByClassName('leaflet-tile-pane')[0].style.opacity = layer.opacity || 1;
Expand Down

0 comments on commit ca25992

Please sign in to comment.