Add image loading events to ImageStatic
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
goog.provide('ol.source.ImageStatic');
|
goog.provide('ol.source.ImageStatic');
|
||||||
|
|
||||||
goog.require('goog.events');
|
goog.require('goog.events');
|
||||||
|
goog.require('goog.events.EventType');
|
||||||
goog.require('ol.Image');
|
goog.require('ol.Image');
|
||||||
goog.require('ol.extent');
|
goog.require('ol.extent');
|
||||||
goog.require('ol.proj');
|
goog.require('ol.proj');
|
||||||
@@ -49,6 +50,8 @@ ol.source.ImageStatic = function(options) {
|
|||||||
*/
|
*/
|
||||||
this.image_ = new ol.Image(imageExtent, resolution, 1, attributions,
|
this.image_ = new ol.Image(imageExtent, resolution, 1, attributions,
|
||||||
options.url, crossOrigin, imageLoadFunction);
|
options.url, crossOrigin, imageLoadFunction);
|
||||||
|
goog.events.listen(this.image_, goog.events.EventType.CHANGE,
|
||||||
|
this.handleImageChange, false, this);
|
||||||
|
|
||||||
};
|
};
|
||||||
goog.inherits(ol.source.ImageStatic, ol.source.Image);
|
goog.inherits(ol.source.ImageStatic, ol.source.Image);
|
||||||
|
|||||||
BIN
test/spec/ol/source/images/12-655-1583.png
Normal file
BIN
test/spec/ol/source/images/12-655-1583.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 31 KiB |
45
test/spec/ol/source/imagestaticsource.test.js
Normal file
45
test/spec/ol/source/imagestaticsource.test.js
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
goog.provide('ol.test.source.ImageStatic');
|
||||||
|
|
||||||
|
describe('ol.source.ImageStatic', function() {
|
||||||
|
|
||||||
|
var extent, pixelRatio, projection, resolution;
|
||||||
|
beforeEach(function() {
|
||||||
|
extent = [
|
||||||
|
-13637278.73946974, 4543799.13271362,
|
||||||
|
-13617443.330629736, 4553927.038961405];
|
||||||
|
pixelRatio = 1;
|
||||||
|
projection = ol.proj.get('EPSG:3857');
|
||||||
|
resolution = 38;
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('#getImage', function() {
|
||||||
|
|
||||||
|
it('triggers image load events', function(done) {
|
||||||
|
var source = new ol.source.ImageStatic({
|
||||||
|
url: 'spec/ol/source/images/12-655-1583.png',
|
||||||
|
imageExtent: [
|
||||||
|
-13629027.891360067, 4539747.983913189,
|
||||||
|
-13619243.951739565, 4549531.923533691],
|
||||||
|
projection: projection,
|
||||||
|
imageSize: [256, 256]
|
||||||
|
});
|
||||||
|
|
||||||
|
var imageloadstart = sinon.spy();
|
||||||
|
var imageloaderror = sinon.spy();
|
||||||
|
|
||||||
|
source.on('imageloadstart', imageloadstart);
|
||||||
|
source.on('imageloaderror', imageloaderror);
|
||||||
|
source.on('imageloadend', function(event) {
|
||||||
|
expect(imageloadstart.callCount).to.be(1);
|
||||||
|
expect(imageloaderror.callCount).to.be(0);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
var image = source.getImage(extent, resolution, pixelRatio, projection);
|
||||||
|
image.load();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
goog.require('ol.source.ImageStatic');
|
||||||
|
goog.require('ol.proj');
|
||||||
Reference in New Issue
Block a user