Transformed
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
goog.provide('ol.ImageTile');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.Tile');
|
||||
goog.require('ol.TileState');
|
||||
goog.require('ol.dom');
|
||||
goog.require('ol.events');
|
||||
goog.require('ol.events.EventType');
|
||||
|
||||
/**
|
||||
* @module ol/ImageTile
|
||||
*/
|
||||
import _ol_ from './index.js';
|
||||
import _ol_Tile_ from './Tile.js';
|
||||
import _ol_TileState_ from './TileState.js';
|
||||
import _ol_dom_ from './dom.js';
|
||||
import _ol_events_ from './events.js';
|
||||
import _ol_events_EventType_ from './events/EventType.js';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
@@ -18,9 +18,9 @@ goog.require('ol.events.EventType');
|
||||
* @param {ol.TileLoadFunctionType} tileLoadFunction Tile load function.
|
||||
* @param {olx.TileOptions=} opt_options Tile options.
|
||||
*/
|
||||
ol.ImageTile = function(tileCoord, state, src, crossOrigin, tileLoadFunction, opt_options) {
|
||||
var _ol_ImageTile_ = function(tileCoord, state, src, crossOrigin, tileLoadFunction, opt_options) {
|
||||
|
||||
ol.Tile.call(this, tileCoord, state, opt_options);
|
||||
_ol_Tile_.call(this, tileCoord, state, opt_options);
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -58,23 +58,24 @@ ol.ImageTile = function(tileCoord, state, src, crossOrigin, tileLoadFunction, op
|
||||
this.tileLoadFunction_ = tileLoadFunction;
|
||||
|
||||
};
|
||||
ol.inherits(ol.ImageTile, ol.Tile);
|
||||
|
||||
_ol_.inherits(_ol_ImageTile_, _ol_Tile_);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.ImageTile.prototype.disposeInternal = function() {
|
||||
if (this.state == ol.TileState.LOADING) {
|
||||
_ol_ImageTile_.prototype.disposeInternal = function() {
|
||||
if (this.state == _ol_TileState_.LOADING) {
|
||||
this.unlistenImage_();
|
||||
this.image_ = ol.ImageTile.getBlankImage();
|
||||
this.image_ = _ol_ImageTile_.getBlankImage();
|
||||
}
|
||||
if (this.interimTile) {
|
||||
this.interimTile.dispose();
|
||||
}
|
||||
this.state = ol.TileState.ABORT;
|
||||
this.state = _ol_TileState_.ABORT;
|
||||
this.changed();
|
||||
ol.Tile.prototype.disposeInternal.call(this);
|
||||
_ol_Tile_.prototype.disposeInternal.call(this);
|
||||
};
|
||||
|
||||
|
||||
@@ -83,7 +84,7 @@ ol.ImageTile.prototype.disposeInternal = function() {
|
||||
* @return {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} Image.
|
||||
* @api
|
||||
*/
|
||||
ol.ImageTile.prototype.getImage = function() {
|
||||
_ol_ImageTile_.prototype.getImage = function() {
|
||||
return this.image_;
|
||||
};
|
||||
|
||||
@@ -91,7 +92,7 @@ ol.ImageTile.prototype.getImage = function() {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.ImageTile.prototype.getKey = function() {
|
||||
_ol_ImageTile_.prototype.getKey = function() {
|
||||
return this.src_;
|
||||
};
|
||||
|
||||
@@ -101,10 +102,10 @@ ol.ImageTile.prototype.getKey = function() {
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
ol.ImageTile.prototype.handleImageError_ = function() {
|
||||
this.state = ol.TileState.ERROR;
|
||||
_ol_ImageTile_.prototype.handleImageError_ = function() {
|
||||
this.state = _ol_TileState_.ERROR;
|
||||
this.unlistenImage_();
|
||||
this.image_ = ol.ImageTile.getBlankImage();
|
||||
this.image_ = _ol_ImageTile_.getBlankImage();
|
||||
this.changed();
|
||||
};
|
||||
|
||||
@@ -114,11 +115,11 @@ ol.ImageTile.prototype.handleImageError_ = function() {
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
ol.ImageTile.prototype.handleImageLoad_ = function() {
|
||||
_ol_ImageTile_.prototype.handleImageLoad_ = function() {
|
||||
if (this.image_.naturalWidth && this.image_.naturalHeight) {
|
||||
this.state = ol.TileState.LOADED;
|
||||
this.state = _ol_TileState_.LOADED;
|
||||
} else {
|
||||
this.state = ol.TileState.EMPTY;
|
||||
this.state = _ol_TileState_.EMPTY;
|
||||
}
|
||||
this.unlistenImage_();
|
||||
this.changed();
|
||||
@@ -129,21 +130,21 @@ ol.ImageTile.prototype.handleImageLoad_ = function() {
|
||||
* @inheritDoc
|
||||
* @api
|
||||
*/
|
||||
ol.ImageTile.prototype.load = function() {
|
||||
if (this.state == ol.TileState.ERROR) {
|
||||
this.state = ol.TileState.IDLE;
|
||||
_ol_ImageTile_.prototype.load = function() {
|
||||
if (this.state == _ol_TileState_.ERROR) {
|
||||
this.state = _ol_TileState_.IDLE;
|
||||
this.image_ = new Image();
|
||||
if (this.crossOrigin_ !== null) {
|
||||
this.image_.crossOrigin = this.crossOrigin_;
|
||||
}
|
||||
}
|
||||
if (this.state == ol.TileState.IDLE) {
|
||||
this.state = ol.TileState.LOADING;
|
||||
if (this.state == _ol_TileState_.IDLE) {
|
||||
this.state = _ol_TileState_.LOADING;
|
||||
this.changed();
|
||||
this.imageListenerKeys_ = [
|
||||
ol.events.listenOnce(this.image_, ol.events.EventType.ERROR,
|
||||
_ol_events_.listenOnce(this.image_, _ol_events_EventType_.ERROR,
|
||||
this.handleImageError_, this),
|
||||
ol.events.listenOnce(this.image_, ol.events.EventType.LOAD,
|
||||
_ol_events_.listenOnce(this.image_, _ol_events_EventType_.LOAD,
|
||||
this.handleImageLoad_, this)
|
||||
];
|
||||
this.tileLoadFunction_(this, this.src_);
|
||||
@@ -156,8 +157,8 @@ ol.ImageTile.prototype.load = function() {
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
ol.ImageTile.prototype.unlistenImage_ = function() {
|
||||
this.imageListenerKeys_.forEach(ol.events.unlistenByKey);
|
||||
_ol_ImageTile_.prototype.unlistenImage_ = function() {
|
||||
this.imageListenerKeys_.forEach(_ol_events_.unlistenByKey);
|
||||
this.imageListenerKeys_ = null;
|
||||
};
|
||||
|
||||
@@ -166,9 +167,10 @@ ol.ImageTile.prototype.unlistenImage_ = function() {
|
||||
* Get a 1-pixel blank image.
|
||||
* @return {HTMLCanvasElement} Blank image.
|
||||
*/
|
||||
ol.ImageTile.getBlankImage = function() {
|
||||
var ctx = ol.dom.createCanvasContext2D(1, 1);
|
||||
_ol_ImageTile_.getBlankImage = function() {
|
||||
var ctx = _ol_dom_.createCanvasContext2D(1, 1);
|
||||
ctx.fillStyle = 'rgba(0,0,0,0)';
|
||||
ctx.fillRect(0, 0, 1, 1);
|
||||
return ctx.canvas;
|
||||
};
|
||||
export default _ol_ImageTile_;
|
||||
|
||||
Reference in New Issue
Block a user