Change ol.ImageState to ol.Image.State

This commit is contained in:
Frederic Junod
2016-08-29 10:53:09 +02:00
parent 1fecb6fd16
commit bed95e3b5b
13 changed files with 79 additions and 81 deletions

View File

@@ -1,8 +1,8 @@
goog.provide('ol.Image');
goog.require('ol');
goog.require('ol.Image');
goog.require('ol.ImageBase');
goog.require('ol.ImageState');
goog.require('ol.events');
goog.require('ol.events.EventType');
goog.require('ol.extent');
@@ -23,7 +23,7 @@ goog.require('ol.obj');
ol.Image = function(extent, resolution, pixelRatio, attributions, src,
crossOrigin, imageLoadFunction) {
ol.ImageBase.call(this, extent, resolution, pixelRatio, ol.ImageState.IDLE,
ol.ImageBase.call(this, extent, resolution, pixelRatio, ol.Image.State.IDLE,
attributions);
/**
@@ -55,9 +55,9 @@ ol.Image = function(extent, resolution, pixelRatio, attributions, src,
/**
* @protected
* @type {ol.ImageState}
* @type {ol.Image.State}
*/
this.state = ol.ImageState.IDLE;
this.state = ol.Image.State.IDLE;
/**
* @private
@@ -100,7 +100,7 @@ ol.Image.prototype.getImage = function(opt_context) {
* @private
*/
ol.Image.prototype.handleImageError_ = function() {
this.state = ol.ImageState.ERROR;
this.state = ol.Image.State.ERROR;
this.unlistenImage_();
this.changed();
};
@@ -115,7 +115,7 @@ ol.Image.prototype.handleImageLoad_ = function() {
if (this.resolution === undefined) {
this.resolution = ol.extent.getHeight(this.extent) / this.image_.height;
}
this.state = ol.ImageState.LOADED;
this.state = ol.Image.State.LOADED;
this.unlistenImage_();
this.changed();
};
@@ -128,8 +128,8 @@ ol.Image.prototype.handleImageLoad_ = function() {
* @api
*/
ol.Image.prototype.load = function() {
if (this.state == ol.ImageState.IDLE || this.state == ol.ImageState.ERROR) {
this.state = ol.ImageState.LOADING;
if (this.state == ol.Image.State.IDLE || this.state == ol.Image.State.ERROR) {
this.state = ol.Image.State.LOADING;
this.changed();
goog.DEBUG && console.assert(!this.imageListenerKeys_,
'this.imageListenerKeys_ should be null');
@@ -161,3 +161,14 @@ ol.Image.prototype.unlistenImage_ = function() {
this.imageListenerKeys_.forEach(ol.events.unlistenByKey);
this.imageListenerKeys_ = null;
};
/**
* @enum {number}
*/
ol.Image.State = {
IDLE: 0,
LOADING: 1,
LOADED: 2,
ERROR: 3
};