Fix tile overzooming

This commit is contained in:
John Firebaugh
2013-06-12 16:49:50 -07:00
parent 0a91918622
commit e339bd5df3
2 changed files with 16 additions and 7 deletions

View File

@@ -17,6 +17,9 @@ img.tile {
img.tile-loaded {
opacity: 1;
}
img.tile-removing {
opacity: 0;
}
/* base styles */
path {

View File

@@ -27,7 +27,10 @@ iD.Background = function(backgroundType) {
function lookUp(d) {
for (var up = -1; up > -d[2]; up--) {
if (cache[atZoom(d, up)] !== false) return atZoom(d, up);
var tile = atZoom(d, up);
if (cache[source(tile)] !== false) {
return tile;
}
}
}
@@ -94,6 +97,7 @@ iD.Background = function(backgroundType) {
function load(d) {
cache[d[3]] = true;
d3.select(this)
.on('error', null)
.on('load', null)
.classed('tile-loaded', true);
render(selection);
@@ -102,6 +106,7 @@ iD.Background = function(backgroundType) {
function error(d) {
cache[d[3]] = false;
d3.select(this)
.on('error', null)
.on('load', null)
.remove();
render(selection);
@@ -122,13 +127,12 @@ iD.Background = function(backgroundType) {
image.exit()
.style(transformProp, imageTransform)
.classed('tile-loaded', false)
.classed('tile-removing', true)
.each(function() {
var tile = this;
var tile = d3.select(this);
window.setTimeout(function() {
// this tile may already be removed
if (tile.parentNode) {
tile.parentNode.removeChild(tile);
if (tile.classed('tile-removing')) {
tile.remove();
}
}, 300);
});
@@ -139,7 +143,9 @@ iD.Background = function(backgroundType) {
.on('error', error)
.on('load', load);
image.style(transformProp, imageTransform);
image
.style(transformProp, imageTransform)
.classed('tile-removing', false);
}
background.offset = function(_) {