diff --git a/src/objectliterals.exports b/src/objectliterals.exports index a6ce462790..0e24207a11 100644 --- a/src/objectliterals.exports +++ b/src/objectliterals.exports @@ -106,6 +106,15 @@ @exportObjectLiteralProperty ol.source.StamenOptions.flavor string|undefined @exportObjectLiteralProperty ol.source.StamenOptions.provider string +@exportObjectLiteral ol.source.StaticImageOptions +@exportObjectLiteralProperty ol.source.StaticImageOptions.attributions Array.|undefined +@exportObjectLiteralProperty ol.source.StaticImageOptions.crossOrigin null|string|undefined +@exportObjectLiteralProperty ol.source.StaticImageOptions.extent ol.Extent|undefined +@exportObjectLiteralProperty ol.source.StaticImageOptions.imageExtent ol.Extent|undefined +@exportObjectLiteralProperty ol.source.StaticImageOptions.imageSize ol.Size|undefined +@exportObjectLiteralProperty ol.source.StaticImageOptions.projection ol.Projection|undefined +@exportObjectLiteralProperty ol.source.StaticImageOptions.url string|undefined + @exportObjectLiteral ol.source.TiledWMSOptions @exportObjectLiteralProperty ol.source.TiledWMSOptions.attributions Array.|undefined @exportObjectLiteralProperty ol.source.TiledWMSOptions.params Object diff --git a/src/ol/source/staticimage.exports b/src/ol/source/staticimage.exports new file mode 100644 index 0000000000..3f7b2c98a5 --- /dev/null +++ b/src/ol/source/staticimage.exports @@ -0,0 +1 @@ +@exportSymbol ol.source.StaticImage diff --git a/src/ol/source/staticimagesource.js b/src/ol/source/staticimagesource.js new file mode 100644 index 0000000000..eafa205eb1 --- /dev/null +++ b/src/ol/source/staticimagesource.js @@ -0,0 +1,61 @@ +goog.provide('ol.source.StaticImage'); + +goog.require('ol.Image'); +goog.require('ol.ImageUrlFunctionType'); +goog.require('ol.source.ImageSource'); + + + +/** + * @constructor + * @extends {ol.source.ImageSource} + * @param {ol.source.StaticImageOptions} options Options. + */ +ol.source.StaticImage = function(options) { + + var imageFunction = ol.source.StaticImage.createImageFunction( + options.url); + + var imageExtent = options.imageExtent; + var imageSize = options.imageSize; + var imageResolution = imageExtent.getHeight() / imageSize.height; + + goog.base(this, { + attributions: options.attributions, + crossOrigin: options.crossOrigin, + extent: options.extent, + projection: options.projection, + imageUrlFunction: imageFunction, + resolutions: [imageResolution] + }); + + /** + * @private + * @type {ol.Image} + */ + this.image_ = this.createImage(imageExtent, imageResolution, imageSize); + +}; +goog.inherits(ol.source.StaticImage, ol.source.ImageSource); + + +/** + * @inheritDoc + */ +ol.source.StaticImage.prototype.getImage = function(extent, resolution) { + if (extent.intersects(this.image_.getExtent())) { + return this.image_; + } + return null; +}; + + +/** + * @param {string|undefined} url URL. + * @return {ol.ImageUrlFunctionType} Function. + */ +ol.source.StaticImage.createImageFunction = function(url) { + return function(extent, size) { + return url; + }; +};