diff --git a/src/ol/source/raster.js b/src/ol/source/raster.js index dcf82ef6ec..3588573adb 100644 --- a/src/ol/source/raster.js +++ b/src/ol/source/raster.js @@ -220,8 +220,6 @@ ol.source.Raster.prototype.getImage = function(extent, resolution, pixelRatio, p var frameState = this.updateFrameState_(extent, resolution, projection); this.requestedFrameState_ = frameState; - frameState.tileQueue.loadMoreTiles(16, 16); - // check if we can't reuse the existing ol.ImageCanvas if (this.renderedImageCanvas_) { var renderedResolution = this.renderedImageCanvas_.getResolution(); @@ -235,6 +233,7 @@ ol.source.Raster.prototype.getImage = function(extent, resolution, pixelRatio, p this.processSources_(); } + frameState.tileQueue.loadMoreTiles(16, 16); return this.renderedImageCanvas_; }; diff --git a/test/spec/ol/source/raster.test.js b/test/spec/ol/source/raster.test.js index bb4cb88ebf..6d4d44458e 100644 --- a/test/spec/ol/source/raster.test.js +++ b/test/spec/ol/source/raster.test.js @@ -1,6 +1,7 @@ goog.provide('ol.test.source.RasterSource'); goog.require('ol.Map'); +goog.require('ol.TileState'); goog.require('ol.View'); goog.require('ol.layer.Image'); goog.require('ol.proj.Projection'); @@ -8,7 +9,7 @@ goog.require('ol.source.ImageStatic'); goog.require('ol.source.Raster'); goog.require('ol.source.Source'); goog.require('ol.source.Tile'); - +goog.require('ol.source.XYZ'); var red = 'data:image/gif;base64,R0lGODlhAQABAPAAAP8AAP///yH5BAAAAAAALAAAAAA' + 'BAAEAAAICRAEAOw=='; @@ -302,4 +303,51 @@ where('Uint8ClampedArray').describe('ol.source.Raster', function() { }); + describe('tile loading', function() { + beforeEach(function() { + map.setTarget(null); + map.dispose(); + }); + + it('is initiated on the underlying source', function(done) { + + var source = new ol.source.XYZ({ + url: 'spec/ol/data/osm-{z}-{x}-{y}.png' + }); + + raster = new ol.source.Raster({ + threads: 0, + sources: [source], + operation: function(inputs) { + return inputs[0]; + } + }); + + map = new ol.Map({ + target: target, + view: new ol.View({ + center: [0, 0], + zoom: 0 + }), + layers: [ + new ol.layer.Image({ + source: raster + }) + ] + }); + + var tileCache = source.tileCache; + + expect(tileCache.getCount()).to.equal(0); + + map.once('moveend', function() { + expect(tileCache.getCount()).to.equal(1); + var state = tileCache.peekLast().getState(); + expect(state === ol.TileState.LOADED || state === ol.TileState.LOADED).to.be(true); + done(); + }); + + }); + }); + });