Dedicated module for image state enum
This commit is contained in:
@@ -2,6 +2,7 @@ goog.provide('ol.Image');
|
|||||||
|
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.ImageBase');
|
goog.require('ol.ImageBase');
|
||||||
|
goog.require('ol.ImageState');
|
||||||
goog.require('ol.events');
|
goog.require('ol.events');
|
||||||
goog.require('ol.events.EventType');
|
goog.require('ol.events.EventType');
|
||||||
goog.require('ol.extent');
|
goog.require('ol.extent');
|
||||||
@@ -22,7 +23,7 @@ goog.require('ol.obj');
|
|||||||
ol.Image = function(extent, resolution, pixelRatio, attributions, src,
|
ol.Image = function(extent, resolution, pixelRatio, attributions, src,
|
||||||
crossOrigin, imageLoadFunction) {
|
crossOrigin, imageLoadFunction) {
|
||||||
|
|
||||||
ol.ImageBase.call(this, extent, resolution, pixelRatio, ol.Image.State.IDLE,
|
ol.ImageBase.call(this, extent, resolution, pixelRatio, ol.ImageState.IDLE,
|
||||||
attributions);
|
attributions);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,9 +55,9 @@ ol.Image = function(extent, resolution, pixelRatio, attributions, src,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
* @type {ol.Image.State}
|
* @type {ol.ImageState}
|
||||||
*/
|
*/
|
||||||
this.state = ol.Image.State.IDLE;
|
this.state = ol.ImageState.IDLE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -99,7 +100,7 @@ ol.Image.prototype.getImage = function(opt_context) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.Image.prototype.handleImageError_ = function() {
|
ol.Image.prototype.handleImageError_ = function() {
|
||||||
this.state = ol.Image.State.ERROR;
|
this.state = ol.ImageState.ERROR;
|
||||||
this.unlistenImage_();
|
this.unlistenImage_();
|
||||||
this.changed();
|
this.changed();
|
||||||
};
|
};
|
||||||
@@ -114,7 +115,7 @@ ol.Image.prototype.handleImageLoad_ = function() {
|
|||||||
if (this.resolution === undefined) {
|
if (this.resolution === undefined) {
|
||||||
this.resolution = ol.extent.getHeight(this.extent) / this.image_.height;
|
this.resolution = ol.extent.getHeight(this.extent) / this.image_.height;
|
||||||
}
|
}
|
||||||
this.state = ol.Image.State.LOADED;
|
this.state = ol.ImageState.LOADED;
|
||||||
this.unlistenImage_();
|
this.unlistenImage_();
|
||||||
this.changed();
|
this.changed();
|
||||||
};
|
};
|
||||||
@@ -127,8 +128,8 @@ ol.Image.prototype.handleImageLoad_ = function() {
|
|||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.Image.prototype.load = function() {
|
ol.Image.prototype.load = function() {
|
||||||
if (this.state == ol.Image.State.IDLE || this.state == ol.Image.State.ERROR) {
|
if (this.state == ol.ImageState.IDLE || this.state == ol.ImageState.ERROR) {
|
||||||
this.state = ol.Image.State.LOADING;
|
this.state = ol.ImageState.LOADING;
|
||||||
this.changed();
|
this.changed();
|
||||||
ol.DEBUG && console.assert(!this.imageListenerKeys_,
|
ol.DEBUG && console.assert(!this.imageListenerKeys_,
|
||||||
'this.imageListenerKeys_ should be null');
|
'this.imageListenerKeys_ should be null');
|
||||||
@@ -160,14 +161,3 @@ ol.Image.prototype.unlistenImage_ = function() {
|
|||||||
this.imageListenerKeys_.forEach(ol.events.unlistenByKey);
|
this.imageListenerKeys_.forEach(ol.events.unlistenByKey);
|
||||||
this.imageListenerKeys_ = null;
|
this.imageListenerKeys_ = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @enum {number}
|
|
||||||
*/
|
|
||||||
ol.Image.State = {
|
|
||||||
IDLE: 0,
|
|
||||||
LOADING: 1,
|
|
||||||
LOADED: 2,
|
|
||||||
ERROR: 3
|
|
||||||
};
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ goog.require('ol.events.EventType');
|
|||||||
* @param {ol.Extent} extent Extent.
|
* @param {ol.Extent} extent Extent.
|
||||||
* @param {number|undefined} resolution Resolution.
|
* @param {number|undefined} resolution Resolution.
|
||||||
* @param {number} pixelRatio Pixel ratio.
|
* @param {number} pixelRatio Pixel ratio.
|
||||||
* @param {ol.Image.State} state State.
|
* @param {ol.ImageState} state State.
|
||||||
* @param {Array.<ol.Attribution>} attributions Attributions.
|
* @param {Array.<ol.Attribution>} attributions Attributions.
|
||||||
*/
|
*/
|
||||||
ol.ImageBase = function(extent, resolution, pixelRatio, state, attributions) {
|
ol.ImageBase = function(extent, resolution, pixelRatio, state, attributions) {
|
||||||
@@ -44,7 +44,7 @@ ol.ImageBase = function(extent, resolution, pixelRatio, state, attributions) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
* @type {ol.Image.State}
|
* @type {ol.ImageState}
|
||||||
*/
|
*/
|
||||||
this.state = state;
|
this.state = state;
|
||||||
|
|
||||||
@@ -102,7 +102,7 @@ ol.ImageBase.prototype.getResolution = function() {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {ol.Image.State} State.
|
* @return {ol.ImageState} State.
|
||||||
*/
|
*/
|
||||||
ol.ImageBase.prototype.getState = function() {
|
ol.ImageBase.prototype.getState = function() {
|
||||||
return this.state;
|
return this.state;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
goog.provide('ol.ImageCanvas');
|
goog.provide('ol.ImageCanvas');
|
||||||
|
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.Image');
|
|
||||||
goog.require('ol.ImageBase');
|
goog.require('ol.ImageBase');
|
||||||
|
goog.require('ol.ImageState');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -27,7 +27,7 @@ ol.ImageCanvas = function(extent, resolution, pixelRatio, attributions,
|
|||||||
this.loader_ = opt_loader !== undefined ? opt_loader : null;
|
this.loader_ = opt_loader !== undefined ? opt_loader : null;
|
||||||
|
|
||||||
var state = opt_loader !== undefined ?
|
var state = opt_loader !== undefined ?
|
||||||
ol.Image.State.IDLE : ol.Image.State.LOADED;
|
ol.ImageState.IDLE : ol.ImageState.LOADED;
|
||||||
|
|
||||||
ol.ImageBase.call(this, extent, resolution, pixelRatio, state, attributions);
|
ol.ImageBase.call(this, extent, resolution, pixelRatio, state, attributions);
|
||||||
|
|
||||||
@@ -64,9 +64,9 @@ ol.ImageCanvas.prototype.getError = function() {
|
|||||||
ol.ImageCanvas.prototype.handleLoad_ = function(err) {
|
ol.ImageCanvas.prototype.handleLoad_ = function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
this.error_ = err;
|
this.error_ = err;
|
||||||
this.state = ol.Image.State.ERROR;
|
this.state = ol.ImageState.ERROR;
|
||||||
} else {
|
} else {
|
||||||
this.state = ol.Image.State.LOADED;
|
this.state = ol.ImageState.LOADED;
|
||||||
}
|
}
|
||||||
this.changed();
|
this.changed();
|
||||||
};
|
};
|
||||||
@@ -76,9 +76,9 @@ ol.ImageCanvas.prototype.handleLoad_ = function(err) {
|
|||||||
* Trigger drawing on canvas.
|
* Trigger drawing on canvas.
|
||||||
*/
|
*/
|
||||||
ol.ImageCanvas.prototype.load = function() {
|
ol.ImageCanvas.prototype.load = function() {
|
||||||
if (this.state == ol.Image.State.IDLE) {
|
if (this.state == ol.ImageState.IDLE) {
|
||||||
ol.DEBUG && console.assert(this.loader_, 'this.loader_ must be set');
|
ol.DEBUG && console.assert(this.loader_, 'this.loader_ must be set');
|
||||||
this.state = ol.Image.State.LOADING;
|
this.state = ol.ImageState.LOADING;
|
||||||
this.changed();
|
this.changed();
|
||||||
this.loader_(this.handleLoad_.bind(this));
|
this.loader_(this.handleLoad_.bind(this));
|
||||||
}
|
}
|
||||||
|
|||||||
11
src/ol/imagestate.js
Normal file
11
src/ol/imagestate.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
goog.provide('ol.ImageState');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @enum {number}
|
||||||
|
*/
|
||||||
|
ol.ImageState = {
|
||||||
|
IDLE: 0,
|
||||||
|
LOADING: 1,
|
||||||
|
LOADED: 2,
|
||||||
|
ERROR: 3
|
||||||
|
};
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
goog.provide('ol.renderer.Layer');
|
goog.provide('ol.renderer.Layer');
|
||||||
|
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.Image');
|
goog.require('ol.ImageState');
|
||||||
goog.require('ol.Observable');
|
goog.require('ol.Observable');
|
||||||
goog.require('ol.Tile');
|
goog.require('ol.Tile');
|
||||||
goog.require('ol.asserts');
|
goog.require('ol.asserts');
|
||||||
@@ -98,7 +98,7 @@ ol.renderer.Layer.prototype.getLayer = function() {
|
|||||||
*/
|
*/
|
||||||
ol.renderer.Layer.prototype.handleImageChange_ = function(event) {
|
ol.renderer.Layer.prototype.handleImageChange_ = function(event) {
|
||||||
var image = /** @type {ol.Image} */ (event.target);
|
var image = /** @type {ol.Image} */ (event.target);
|
||||||
if (image.getState() === ol.Image.State.LOADED) {
|
if (image.getState() === ol.ImageState.LOADED) {
|
||||||
this.renderIfReadyAndVisible();
|
this.renderIfReadyAndVisible();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -114,24 +114,24 @@ ol.renderer.Layer.prototype.handleImageChange_ = function(event) {
|
|||||||
*/
|
*/
|
||||||
ol.renderer.Layer.prototype.loadImage = function(image) {
|
ol.renderer.Layer.prototype.loadImage = function(image) {
|
||||||
var imageState = image.getState();
|
var imageState = image.getState();
|
||||||
if (imageState != ol.Image.State.LOADED &&
|
if (imageState != ol.ImageState.LOADED &&
|
||||||
imageState != ol.Image.State.ERROR) {
|
imageState != ol.ImageState.ERROR) {
|
||||||
// the image is either "idle" or "loading", register the change
|
// the image is either "idle" or "loading", register the change
|
||||||
// listener (a noop if the listener was already registered)
|
// listener (a noop if the listener was already registered)
|
||||||
ol.DEBUG && console.assert(imageState == ol.Image.State.IDLE ||
|
ol.DEBUG && console.assert(imageState == ol.ImageState.IDLE ||
|
||||||
imageState == ol.Image.State.LOADING,
|
imageState == ol.ImageState.LOADING,
|
||||||
'imageState is "idle" or "loading"');
|
'imageState is "idle" or "loading"');
|
||||||
ol.events.listen(image, ol.events.EventType.CHANGE,
|
ol.events.listen(image, ol.events.EventType.CHANGE,
|
||||||
this.handleImageChange_, this);
|
this.handleImageChange_, this);
|
||||||
}
|
}
|
||||||
if (imageState == ol.Image.State.IDLE) {
|
if (imageState == ol.ImageState.IDLE) {
|
||||||
image.load();
|
image.load();
|
||||||
imageState = image.getState();
|
imageState = image.getState();
|
||||||
ol.DEBUG && console.assert(imageState == ol.Image.State.LOADING ||
|
ol.DEBUG && console.assert(imageState == ol.ImageState.LOADING ||
|
||||||
imageState == ol.Image.State.LOADED,
|
imageState == ol.ImageState.LOADED,
|
||||||
'imageState is "loading" or "loaded"');
|
'imageState is "loading" or "loaded"');
|
||||||
}
|
}
|
||||||
return imageState == ol.Image.State.LOADED;
|
return imageState == ol.ImageState.LOADED;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
goog.provide('ol.renderer.vector');
|
goog.provide('ol.renderer.vector');
|
||||||
|
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.Image');
|
goog.require('ol.ImageState');
|
||||||
goog.require('ol.render.ReplayType');
|
goog.require('ol.render.ReplayType');
|
||||||
|
|
||||||
|
|
||||||
@@ -79,15 +79,15 @@ ol.renderer.vector.renderFeature = function(
|
|||||||
imageStyle = style.getImage();
|
imageStyle = style.getImage();
|
||||||
if (imageStyle) {
|
if (imageStyle) {
|
||||||
imageState = imageStyle.getImageState();
|
imageState = imageStyle.getImageState();
|
||||||
if (imageState == ol.Image.State.LOADED ||
|
if (imageState == ol.ImageState.LOADED ||
|
||||||
imageState == ol.Image.State.ERROR) {
|
imageState == ol.ImageState.ERROR) {
|
||||||
imageStyle.unlistenImageChange(listener, thisArg);
|
imageStyle.unlistenImageChange(listener, thisArg);
|
||||||
} else {
|
} else {
|
||||||
if (imageState == ol.Image.State.IDLE) {
|
if (imageState == ol.ImageState.IDLE) {
|
||||||
imageStyle.load();
|
imageStyle.load();
|
||||||
}
|
}
|
||||||
imageState = imageStyle.getImageState();
|
imageState = imageStyle.getImageState();
|
||||||
ol.DEBUG && console.assert(imageState == ol.Image.State.LOADING,
|
ol.DEBUG && console.assert(imageState == ol.ImageState.LOADING,
|
||||||
'imageState should be LOADING');
|
'imageState should be LOADING');
|
||||||
imageStyle.listenImageChange(listener, thisArg);
|
imageStyle.listenImageChange(listener, thisArg);
|
||||||
loading = true;
|
loading = true;
|
||||||
@@ -227,7 +227,7 @@ ol.renderer.vector.renderMultiPolygonGeometry_ = function(replayGroup, geometry,
|
|||||||
ol.renderer.vector.renderPointGeometry_ = function(replayGroup, geometry, style, feature) {
|
ol.renderer.vector.renderPointGeometry_ = function(replayGroup, geometry, style, feature) {
|
||||||
var imageStyle = style.getImage();
|
var imageStyle = style.getImage();
|
||||||
if (imageStyle) {
|
if (imageStyle) {
|
||||||
if (imageStyle.getImageState() != ol.Image.State.LOADED) {
|
if (imageStyle.getImageState() != ol.ImageState.LOADED) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var imageReplay = replayGroup.getReplay(
|
var imageReplay = replayGroup.getReplay(
|
||||||
@@ -256,7 +256,7 @@ ol.renderer.vector.renderPointGeometry_ = function(replayGroup, geometry, style,
|
|||||||
ol.renderer.vector.renderMultiPointGeometry_ = function(replayGroup, geometry, style, feature) {
|
ol.renderer.vector.renderMultiPointGeometry_ = function(replayGroup, geometry, style, feature) {
|
||||||
var imageStyle = style.getImage();
|
var imageStyle = style.getImage();
|
||||||
if (imageStyle) {
|
if (imageStyle) {
|
||||||
if (imageStyle.getImageState() != ol.Image.State.LOADED) {
|
if (imageStyle.getImageState() != ol.ImageState.LOADED) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var imageReplay = replayGroup.getReplay(
|
var imageReplay = replayGroup.getReplay(
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
goog.provide('ol.reproj.Image');
|
goog.provide('ol.reproj.Image');
|
||||||
|
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.Image');
|
|
||||||
goog.require('ol.ImageBase');
|
goog.require('ol.ImageBase');
|
||||||
|
goog.require('ol.ImageState');
|
||||||
goog.require('ol.events');
|
goog.require('ol.events');
|
||||||
goog.require('ol.events.EventType');
|
goog.require('ol.events.EventType');
|
||||||
goog.require('ol.extent');
|
goog.require('ol.extent');
|
||||||
@@ -99,11 +99,11 @@ ol.reproj.Image = function(sourceProj, targetProj,
|
|||||||
this.sourceListenerKey_ = null;
|
this.sourceListenerKey_ = null;
|
||||||
|
|
||||||
|
|
||||||
var state = ol.Image.State.LOADED;
|
var state = ol.ImageState.LOADED;
|
||||||
var attributions = [];
|
var attributions = [];
|
||||||
|
|
||||||
if (this.sourceImage_) {
|
if (this.sourceImage_) {
|
||||||
state = ol.Image.State.IDLE;
|
state = ol.ImageState.IDLE;
|
||||||
attributions = this.sourceImage_.getAttributions();
|
attributions = this.sourceImage_.getAttributions();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,7 +117,7 @@ ol.inherits(ol.reproj.Image, ol.ImageBase);
|
|||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.reproj.Image.prototype.disposeInternal = function() {
|
ol.reproj.Image.prototype.disposeInternal = function() {
|
||||||
if (this.state == ol.Image.State.LOADING) {
|
if (this.state == ol.ImageState.LOADING) {
|
||||||
this.unlistenSource_();
|
this.unlistenSource_();
|
||||||
}
|
}
|
||||||
ol.ImageBase.prototype.disposeInternal.call(this);
|
ol.ImageBase.prototype.disposeInternal.call(this);
|
||||||
@@ -145,7 +145,7 @@ ol.reproj.Image.prototype.getProjection = function() {
|
|||||||
*/
|
*/
|
||||||
ol.reproj.Image.prototype.reproject_ = function() {
|
ol.reproj.Image.prototype.reproject_ = function() {
|
||||||
var sourceState = this.sourceImage_.getState();
|
var sourceState = this.sourceImage_.getState();
|
||||||
if (sourceState == ol.Image.State.LOADED) {
|
if (sourceState == ol.ImageState.LOADED) {
|
||||||
var width = ol.extent.getWidth(this.targetExtent_) / this.targetResolution_;
|
var width = ol.extent.getWidth(this.targetExtent_) / this.targetResolution_;
|
||||||
var height =
|
var height =
|
||||||
ol.extent.getHeight(this.targetExtent_) / this.targetResolution_;
|
ol.extent.getHeight(this.targetExtent_) / this.targetResolution_;
|
||||||
@@ -166,20 +166,20 @@ ol.reproj.Image.prototype.reproject_ = function() {
|
|||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.reproj.Image.prototype.load = function() {
|
ol.reproj.Image.prototype.load = function() {
|
||||||
if (this.state == ol.Image.State.IDLE) {
|
if (this.state == ol.ImageState.IDLE) {
|
||||||
this.state = ol.Image.State.LOADING;
|
this.state = ol.ImageState.LOADING;
|
||||||
this.changed();
|
this.changed();
|
||||||
|
|
||||||
var sourceState = this.sourceImage_.getState();
|
var sourceState = this.sourceImage_.getState();
|
||||||
if (sourceState == ol.Image.State.LOADED ||
|
if (sourceState == ol.ImageState.LOADED ||
|
||||||
sourceState == ol.Image.State.ERROR) {
|
sourceState == ol.ImageState.ERROR) {
|
||||||
this.reproject_();
|
this.reproject_();
|
||||||
} else {
|
} else {
|
||||||
this.sourceListenerKey_ = ol.events.listen(this.sourceImage_,
|
this.sourceListenerKey_ = ol.events.listen(this.sourceImage_,
|
||||||
ol.events.EventType.CHANGE, function(e) {
|
ol.events.EventType.CHANGE, function(e) {
|
||||||
var sourceState = this.sourceImage_.getState();
|
var sourceState = this.sourceImage_.getState();
|
||||||
if (sourceState == ol.Image.State.LOADED ||
|
if (sourceState == ol.ImageState.LOADED ||
|
||||||
sourceState == ol.Image.State.ERROR) {
|
sourceState == ol.ImageState.ERROR) {
|
||||||
this.unlistenSource_();
|
this.unlistenSource_();
|
||||||
this.reproject_();
|
this.reproject_();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
goog.provide('ol.source.Image');
|
goog.provide('ol.source.Image');
|
||||||
|
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.Image');
|
goog.require('ol.ImageState');
|
||||||
goog.require('ol.array');
|
goog.require('ol.array');
|
||||||
goog.require('ol.events.Event');
|
goog.require('ol.events.Event');
|
||||||
goog.require('ol.extent');
|
goog.require('ol.extent');
|
||||||
@@ -147,17 +147,17 @@ ol.source.Image.prototype.getImageInternal = function(extent, resolution, pixelR
|
|||||||
ol.source.Image.prototype.handleImageChange = function(event) {
|
ol.source.Image.prototype.handleImageChange = function(event) {
|
||||||
var image = /** @type {ol.Image} */ (event.target);
|
var image = /** @type {ol.Image} */ (event.target);
|
||||||
switch (image.getState()) {
|
switch (image.getState()) {
|
||||||
case ol.Image.State.LOADING:
|
case ol.ImageState.LOADING:
|
||||||
this.dispatchEvent(
|
this.dispatchEvent(
|
||||||
new ol.source.Image.Event(ol.source.Image.EventType.IMAGELOADSTART,
|
new ol.source.Image.Event(ol.source.Image.EventType.IMAGELOADSTART,
|
||||||
image));
|
image));
|
||||||
break;
|
break;
|
||||||
case ol.Image.State.LOADED:
|
case ol.ImageState.LOADED:
|
||||||
this.dispatchEvent(
|
this.dispatchEvent(
|
||||||
new ol.source.Image.Event(ol.source.Image.EventType.IMAGELOADEND,
|
new ol.source.Image.Event(ol.source.Image.EventType.IMAGELOADEND,
|
||||||
image));
|
image));
|
||||||
break;
|
break;
|
||||||
case ol.Image.State.ERROR:
|
case ol.ImageState.ERROR:
|
||||||
this.dispatchEvent(
|
this.dispatchEvent(
|
||||||
new ol.source.Image.Event(ol.source.Image.EventType.IMAGELOADERROR,
|
new ol.source.Image.Event(ol.source.Image.EventType.IMAGELOADERROR,
|
||||||
image));
|
image));
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ goog.provide('ol.source.ImageStatic');
|
|||||||
|
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.Image');
|
goog.require('ol.Image');
|
||||||
|
goog.require('ol.ImageState');
|
||||||
goog.require('ol.dom');
|
goog.require('ol.dom');
|
||||||
goog.require('ol.events');
|
goog.require('ol.events');
|
||||||
goog.require('ol.events.EventType');
|
goog.require('ol.events.EventType');
|
||||||
@@ -70,7 +71,7 @@ ol.source.ImageStatic.prototype.getImageInternal = function(extent, resolution,
|
|||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.source.ImageStatic.prototype.handleImageChange = function(evt) {
|
ol.source.ImageStatic.prototype.handleImageChange = function(evt) {
|
||||||
if (this.image_.getState() == ol.Image.State.LOADED) {
|
if (this.image_.getState() == ol.ImageState.LOADED) {
|
||||||
var imageExtent = this.image_.getExtent();
|
var imageExtent = this.image_.getExtent();
|
||||||
var image = this.image_.getImage();
|
var image = this.image_.getImage();
|
||||||
var imageWidth, imageHeight;
|
var imageWidth, imageHeight;
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
goog.provide('ol.style.Icon');
|
goog.provide('ol.style.Icon');
|
||||||
|
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
|
goog.require('ol.ImageState');
|
||||||
goog.require('ol.asserts');
|
goog.require('ol.asserts');
|
||||||
goog.require('ol.color');
|
goog.require('ol.color');
|
||||||
goog.require('ol.events');
|
goog.require('ol.events');
|
||||||
goog.require('ol.events.EventType');
|
goog.require('ol.events.EventType');
|
||||||
goog.require('ol.Image');
|
|
||||||
goog.require('ol.style.IconImage');
|
goog.require('ol.style.IconImage');
|
||||||
goog.require('ol.style.Image');
|
goog.require('ol.style.Image');
|
||||||
|
|
||||||
@@ -90,10 +90,10 @@ ol.style.Icon = function(opt_options) {
|
|||||||
6); // A defined and non-empty `src` or `image` must be provided
|
6); // A defined and non-empty `src` or `image` must be provided
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {ol.Image.State}
|
* @type {ol.ImageState}
|
||||||
*/
|
*/
|
||||||
var imageState = options.src !== undefined ?
|
var imageState = options.src !== undefined ?
|
||||||
ol.Image.State.IDLE : ol.Image.State.LOADED;
|
ol.ImageState.IDLE : ol.ImageState.LOADED;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -181,7 +181,7 @@ ol.inherits(ol.style.Icon, ol.style.Image);
|
|||||||
ol.style.Icon.prototype.clone = function() {
|
ol.style.Icon.prototype.clone = function() {
|
||||||
var oldImage = this.getImage(1);
|
var oldImage = this.getImage(1);
|
||||||
var newImage;
|
var newImage;
|
||||||
if (this.iconImage_.getImageState() === ol.Image.State.LOADED) {
|
if (this.iconImage_.getImageState() === ol.ImageState.LOADED) {
|
||||||
if (oldImage.tagName.toUpperCase() === 'IMG') {
|
if (oldImage.tagName.toUpperCase() === 'IMG') {
|
||||||
newImage = /** @type {Image} */ (oldImage.cloneNode(true));
|
newImage = /** @type {Image} */ (oldImage.cloneNode(true));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ goog.require('ol.dom');
|
|||||||
goog.require('ol.events');
|
goog.require('ol.events');
|
||||||
goog.require('ol.events.EventTarget');
|
goog.require('ol.events.EventTarget');
|
||||||
goog.require('ol.events.EventType');
|
goog.require('ol.events.EventType');
|
||||||
goog.require('ol.Image');
|
goog.require('ol.ImageState');
|
||||||
goog.require('ol.style');
|
goog.require('ol.style');
|
||||||
|
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ goog.require('ol.style');
|
|||||||
* @param {string|undefined} src Src.
|
* @param {string|undefined} src Src.
|
||||||
* @param {ol.Size} size Size.
|
* @param {ol.Size} size Size.
|
||||||
* @param {?string} crossOrigin Cross origin.
|
* @param {?string} crossOrigin Cross origin.
|
||||||
* @param {ol.Image.State} imageState Image state.
|
* @param {ol.ImageState} imageState Image state.
|
||||||
* @param {ol.Color} color Color.
|
* @param {ol.Color} color Color.
|
||||||
* @extends {ol.events.EventTarget}
|
* @extends {ol.events.EventTarget}
|
||||||
*/
|
*/
|
||||||
@@ -62,7 +62,7 @@ ol.style.IconImage = function(image, src, size, crossOrigin, imageState,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {ol.Image.State}
|
* @type {ol.ImageState}
|
||||||
*/
|
*/
|
||||||
this.imageState_ = imageState;
|
this.imageState_ = imageState;
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ ol.style.IconImage = function(image, src, size, crossOrigin, imageState,
|
|||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
this.tainting_ = false;
|
this.tainting_ = false;
|
||||||
if (this.imageState_ == ol.Image.State.LOADED) {
|
if (this.imageState_ == ol.ImageState.LOADED) {
|
||||||
this.determineTainting_();
|
this.determineTainting_();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ ol.inherits(ol.style.IconImage, ol.events.EventTarget);
|
|||||||
* @param {string} src Src.
|
* @param {string} src Src.
|
||||||
* @param {ol.Size} size Size.
|
* @param {ol.Size} size Size.
|
||||||
* @param {?string} crossOrigin Cross origin.
|
* @param {?string} crossOrigin Cross origin.
|
||||||
* @param {ol.Image.State} imageState Image state.
|
* @param {ol.ImageState} imageState Image state.
|
||||||
* @param {ol.Color} color Color.
|
* @param {ol.Color} color Color.
|
||||||
* @return {ol.style.IconImage} Icon image.
|
* @return {ol.style.IconImage} Icon image.
|
||||||
*/
|
*/
|
||||||
@@ -139,7 +139,7 @@ ol.style.IconImage.prototype.dispatchChangeEvent_ = function() {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.style.IconImage.prototype.handleImageError_ = function() {
|
ol.style.IconImage.prototype.handleImageError_ = function() {
|
||||||
this.imageState_ = ol.Image.State.ERROR;
|
this.imageState_ = ol.ImageState.ERROR;
|
||||||
this.unlistenImage_();
|
this.unlistenImage_();
|
||||||
this.dispatchChangeEvent_();
|
this.dispatchChangeEvent_();
|
||||||
};
|
};
|
||||||
@@ -149,7 +149,7 @@ ol.style.IconImage.prototype.handleImageError_ = function() {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.style.IconImage.prototype.handleImageLoad_ = function() {
|
ol.style.IconImage.prototype.handleImageLoad_ = function() {
|
||||||
this.imageState_ = ol.Image.State.LOADED;
|
this.imageState_ = ol.ImageState.LOADED;
|
||||||
if (this.size_) {
|
if (this.size_) {
|
||||||
this.image_.width = this.size_[0];
|
this.image_.width = this.size_[0];
|
||||||
this.image_.height = this.size_[1];
|
this.image_.height = this.size_[1];
|
||||||
@@ -172,7 +172,7 @@ ol.style.IconImage.prototype.getImage = function(pixelRatio) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {ol.Image.State} Image state.
|
* @return {ol.ImageState} Image state.
|
||||||
*/
|
*/
|
||||||
ol.style.IconImage.prototype.getImageState = function() {
|
ol.style.IconImage.prototype.getImageState = function() {
|
||||||
return this.imageState_;
|
return this.imageState_;
|
||||||
@@ -219,12 +219,12 @@ ol.style.IconImage.prototype.getSrc = function() {
|
|||||||
* Load not yet loaded URI.
|
* Load not yet loaded URI.
|
||||||
*/
|
*/
|
||||||
ol.style.IconImage.prototype.load = function() {
|
ol.style.IconImage.prototype.load = function() {
|
||||||
if (this.imageState_ == ol.Image.State.IDLE) {
|
if (this.imageState_ == ol.ImageState.IDLE) {
|
||||||
ol.DEBUG && console.assert(this.src_ !== undefined,
|
ol.DEBUG && console.assert(this.src_ !== undefined,
|
||||||
'this.src_ must not be undefined');
|
'this.src_ must not be undefined');
|
||||||
ol.DEBUG && console.assert(!this.imageListenerKeys_,
|
ol.DEBUG && console.assert(!this.imageListenerKeys_,
|
||||||
'no listener keys existing');
|
'no listener keys existing');
|
||||||
this.imageState_ = ol.Image.State.LOADING;
|
this.imageState_ = ol.ImageState.LOADING;
|
||||||
this.imageListenerKeys_ = [
|
this.imageListenerKeys_ = [
|
||||||
ol.events.listenOnce(this.image_, ol.events.EventType.ERROR,
|
ol.events.listenOnce(this.image_, ol.events.EventType.ERROR,
|
||||||
this.handleImageError_, this),
|
this.handleImageError_, this),
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ ol.style.Image.prototype.getHitDetectionImage = function(pixelRatio) {};
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @abstract
|
* @abstract
|
||||||
* @return {ol.Image.State} Image state.
|
* @return {ol.ImageState} Image state.
|
||||||
*/
|
*/
|
||||||
ol.style.Image.prototype.getImageState = function() {};
|
ol.style.Image.prototype.getImageState = function() {};
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ goog.require('ol');
|
|||||||
goog.require('ol.colorlike');
|
goog.require('ol.colorlike');
|
||||||
goog.require('ol.dom');
|
goog.require('ol.dom');
|
||||||
goog.require('ol.has');
|
goog.require('ol.has');
|
||||||
goog.require('ol.Image');
|
goog.require('ol.ImageState');
|
||||||
goog.require('ol.render.canvas');
|
goog.require('ol.render.canvas');
|
||||||
goog.require('ol.style.Image');
|
goog.require('ol.style.Image');
|
||||||
|
|
||||||
@@ -234,7 +234,7 @@ ol.style.RegularShape.prototype.getHitDetectionImageSize = function() {
|
|||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.style.RegularShape.prototype.getImageState = function() {
|
ol.style.RegularShape.prototype.getImageState = function() {
|
||||||
return ol.Image.State.LOADED;
|
return ol.ImageState.LOADED;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user