Remove static members from ImageSource
This commit is contained in:
@@ -41,6 +41,32 @@ const ImageSourceEventType = {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* Events emitted by {@link ol.source.Image} instances are instances of this
|
||||
* type.
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.events.Event}
|
||||
* @implements {oli.source.ImageEvent}
|
||||
* @param {string} type Type.
|
||||
* @param {ol.Image} image The image.
|
||||
*/
|
||||
const ImageSourceEvent = function(type, image) {
|
||||
|
||||
Event.call(this, type);
|
||||
|
||||
/**
|
||||
* The image related to the event.
|
||||
* @type {ol.Image}
|
||||
* @api
|
||||
*/
|
||||
this.image = image;
|
||||
|
||||
};
|
||||
inherits(ImageSourceEvent, Event);
|
||||
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* Abstract base class; normally only used for creating subclasses and not
|
||||
@@ -174,17 +200,17 @@ ImageSource.prototype.handleImageChange = function(event) {
|
||||
switch (image.getState()) {
|
||||
case ImageState.LOADING:
|
||||
this.dispatchEvent(
|
||||
new ImageSource.Event(ImageSourceEventType.IMAGELOADSTART,
|
||||
new ImageSourceEvent(ImageSourceEventType.IMAGELOADSTART,
|
||||
image));
|
||||
break;
|
||||
case ImageState.LOADED:
|
||||
this.dispatchEvent(
|
||||
new ImageSource.Event(ImageSourceEventType.IMAGELOADEND,
|
||||
new ImageSourceEvent(ImageSourceEventType.IMAGELOADEND,
|
||||
image));
|
||||
break;
|
||||
case ImageState.ERROR:
|
||||
this.dispatchEvent(
|
||||
new ImageSource.Event(ImageSourceEventType.IMAGELOADERROR,
|
||||
new ImageSourceEvent(ImageSourceEventType.IMAGELOADERROR,
|
||||
image));
|
||||
break;
|
||||
default:
|
||||
@@ -199,35 +225,9 @@ ImageSource.prototype.handleImageChange = function(event) {
|
||||
* @param {ol.Image} image Image.
|
||||
* @param {string} src Source.
|
||||
*/
|
||||
ImageSource.defaultImageLoadFunction = function(image, src) {
|
||||
export function defaultImageLoadFunction(image, src) {
|
||||
image.getImage().src = src;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* Events emitted by {@link ol.source.Image} instances are instances of this
|
||||
* type.
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.events.Event}
|
||||
* @implements {oli.source.ImageEvent}
|
||||
* @param {string} type Type.
|
||||
* @param {ol.Image} image The image.
|
||||
*/
|
||||
ImageSource.Event = function(type, image) {
|
||||
|
||||
Event.call(this, type);
|
||||
|
||||
/**
|
||||
* The image related to the event.
|
||||
* @type {ol.Image}
|
||||
* @api
|
||||
*/
|
||||
this.image = image;
|
||||
|
||||
};
|
||||
inherits(ImageSource.Event, Event);
|
||||
}
|
||||
|
||||
|
||||
export default ImageSource;
|
||||
|
||||
@@ -8,7 +8,7 @@ import {listen} from '../events.js';
|
||||
import EventType from '../events/EventType.js';
|
||||
import {containsExtent, getHeight, getWidth} from '../extent.js';
|
||||
import {assign} from '../obj.js';
|
||||
import ImageSource from '../source/Image.js';
|
||||
import ImageSource, {defaultImageLoadFunction} from '../source/Image.js';
|
||||
import {appendParams} from '../uri.js';
|
||||
|
||||
/**
|
||||
@@ -60,7 +60,7 @@ const ImageArcGISRest = function(opt_options) {
|
||||
* @type {ol.ImageLoadFunctionType}
|
||||
*/
|
||||
this.imageLoadFunction_ = options.imageLoadFunction !== undefined ?
|
||||
options.imageLoadFunction : ImageSource.defaultImageLoadFunction;
|
||||
options.imageLoadFunction : defaultImageLoadFunction;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,7 +7,7 @@ import {listen} from '../events.js';
|
||||
import EventType from '../events/EventType.js';
|
||||
import {containsExtent, getCenter, getHeight, getWidth, scaleFromCenter} from '../extent.js';
|
||||
import {assign} from '../obj.js';
|
||||
import ImageSource from '../source/Image.js';
|
||||
import ImageSource, {defaultImageLoadFunction} from '../source/Image.js';
|
||||
import {appendParams} from '../uri.js';
|
||||
|
||||
/**
|
||||
@@ -58,7 +58,7 @@ const ImageMapGuide = function(options) {
|
||||
* @type {ol.ImageLoadFunctionType}
|
||||
*/
|
||||
this.imageLoadFunction_ = options.imageLoadFunction !== undefined ?
|
||||
options.imageLoadFunction : ImageSource.defaultImageLoadFunction;
|
||||
options.imageLoadFunction : defaultImageLoadFunction;
|
||||
|
||||
/**
|
||||
* @private
|
||||
|
||||
@@ -9,7 +9,7 @@ import {listen} from '../events.js';
|
||||
import EventType from '../events/EventType.js';
|
||||
import {intersects, getHeight, getWidth} from '../extent.js';
|
||||
import {get as getProjection} from '../proj.js';
|
||||
import ImageSource from '../source/Image.js';
|
||||
import ImageSource, {defaultImageLoadFunction} from '../source/Image.js';
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
@@ -28,7 +28,7 @@ const Static = function(options) {
|
||||
|
||||
const /** @type {ol.ImageLoadFunctionType} */ imageLoadFunction =
|
||||
options.imageLoadFunction !== undefined ?
|
||||
options.imageLoadFunction : ImageSource.defaultImageLoadFunction;
|
||||
options.imageLoadFunction : defaultImageLoadFunction;
|
||||
|
||||
ImageSource.call(this, {
|
||||
attributions: options.attributions,
|
||||
|
||||
@@ -12,7 +12,7 @@ import {containsExtent, getCenter, getForViewAndSize, getHeight, getWidth} from
|
||||
import {assign} from '../obj.js';
|
||||
import {get as getProjection, transform} from '../proj.js';
|
||||
import {calculateSourceResolution} from '../reproj.js';
|
||||
import ImageSource from '../source/Image.js';
|
||||
import ImageSource, {defaultImageLoadFunction} from '../source/Image.js';
|
||||
import WMSServerType from '../source/WMSServerType.js';
|
||||
import {compareVersions} from '../string.js';
|
||||
import {appendParams} from '../uri.js';
|
||||
@@ -55,7 +55,7 @@ const ImageWMS = function(opt_options) {
|
||||
* @type {ol.ImageLoadFunctionType}
|
||||
*/
|
||||
this.imageLoadFunction_ = options.imageLoadFunction !== undefined ?
|
||||
options.imageLoadFunction : ImageSource.defaultImageLoadFunction;
|
||||
options.imageLoadFunction : defaultImageLoadFunction;
|
||||
|
||||
/**
|
||||
* @private
|
||||
|
||||
Reference in New Issue
Block a user