From 39d7388a2fd9615f6bc22569b0448b1e953e938b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20S=C3=A1nchez=20Ortega?= Date: Fri, 5 Feb 2016 17:07:03 +0100 Subject: [PATCH] Revert back to "prune tiles every tileready" behaviour --- debug/map/zoompan.html | 5 +++++ debug/tests/tile-events.html | 33 +++++++++++++++++++++++++++++---- src/layer/tile/GridLayer.js | 2 +- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/debug/map/zoompan.html b/debug/map/zoompan.html index 2da8d806..5ad290b0 100644 --- a/debug/map/zoompan.html +++ b/debug/map/zoompan.html @@ -41,6 +41,7 @@ on move on moveend on zoomend + on grid load diff --git a/debug/tests/tile-events.html b/debug/tests/tile-events.html index f0524f5a..3066c13f 100644 --- a/debug/tests/tile-events.html +++ b/debug/tests/tile-events.html @@ -76,7 +76,7 @@ var mapopts = { center: [35, -122], zoom : 5.7, - fadeAnimation: false + fadeAnimation: true }; var kyiv = [50.5, 30.5], @@ -91,7 +91,7 @@ var positron = L.tileLayer('http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png', { attribution: '© OpenStreetMap contributors, © CartoDB' - }).addTo(map); + }) var grid = L.gridLayer({ attribution: 'Grid Layer', @@ -127,10 +127,35 @@ positron.on('tileload tileunload tileerror tileloadstart load', function(ev){ document.getElementById('positron-' + ev.type).innerHTML = ++counts[ev.type]; - document.getElementById('positron-visible').innerHTML = positron._container.querySelectorAll('.leaflet-tile').length; +// document.getElementById('positron-visible').innerHTML = positron._container.querySelectorAll('.leaflet-tile').length; }); - map.addLayer(grid); +// positron.createTile = function (coords, done) { +// var tile = document.createElement('img'); +// +// L.DomEvent.on(tile, 'load', L.bind(this._tileOnLoad, this, done, tile)); +// L.DomEvent.on(tile, 'error', L.bind(this._tileOnError, this, done, tile)); +// +// if (this.options.crossOrigin) { +// tile.crossOrigin = ''; +// } +// +// /* +// Alt tag is set to empty string to keep screen readers from reading URL and for compliance reasons +// http://www.w3.org/TR/WCAG20-TECHS/H67 +// */ +// tile.alt = ''; +// +// var url = this.getTileUrl(coords); +// setTimeout(function() { +// tile.src = url; +// }, 50 + Math.random() * 3950); +// +// return tile; +// }, + + map.addLayer(positron); +// map.addLayer(grid); document.getElementById('dc').onclick = function () { map.flyTo(dc, 10); }; diff --git a/src/layer/tile/GridLayer.js b/src/layer/tile/GridLayer.js index d2e83a71..6f83232c 100644 --- a/src/layer/tile/GridLayer.js +++ b/src/layer/tile/GridLayer.js @@ -654,7 +654,7 @@ L.GridLayer = L.Layer.extend({ this._fadeFrame = L.Util.requestAnimFrame(this._updateOpacity, this); } else { tile.active = true; -// this._pruneTiles(); + this._pruneTiles(); } L.DomUtil.addClass(tile.el, 'leaflet-tile-loaded');