Only listen for load once. Remove tiles on error

This commit is contained in:
Tom MacWright
2012-12-06 18:01:57 -05:00
parent 3b7af751f4
commit 54ff10ca6a
+11 -3
View File
@@ -67,12 +67,20 @@ iD.Background = function() {
image.exit().remove();
function load(d) {
cache[d] = true;
d3.select(this).on('load', null);
}
function error() {
d3.select(this).remove();
}
image.enter().append('img')
.attr('class', 'tile')
.attr('src', function(d) { return d[3]; })
.on('load', function(d) {
cache[d] = true;
});
.on('error', error)
.on('load', load);
function tileSize(d) {
return Math.ceil(256 * Math.pow(2, z - d[2])) / 256;