Merge pull request #8708 from wallw-bits/fix-typecheck-imagecanvas
Fix type checks in ImageCanvas source
This commit is contained in:
@@ -32,7 +32,7 @@ import ImageSource from '../source/Image.js';
|
|||||||
* projection. The canvas returned by this function is cached by the source. If
|
* projection. The canvas returned by this function is cached by the source. If
|
||||||
* the value returned by the function is later changed then
|
* the value returned by the function is later changed then
|
||||||
* `changed` should be called on the source for the source to
|
* `changed` should be called on the source for the source to
|
||||||
* invalidate the current cached image. See @link: {@link module:ol/Observable~Observable#changed}
|
* invalidate the current cached image. See: {@link module:ol/Observable~Observable#changed}
|
||||||
* @property {import("../proj.js").ProjectionLike} projection Projection.
|
* @property {import("../proj.js").ProjectionLike} projection Projection.
|
||||||
* @property {number} [ratio=1.5] Ratio. 1 means canvases are the size of the map viewport, 2 means twice the
|
* @property {number} [ratio=1.5] Ratio. 1 means canvases are the size of the map viewport, 2 means twice the
|
||||||
* width and height of the map viewport, and so on. Must be `1` or higher.
|
* width and height of the map viewport, and so on. Must be `1` or higher.
|
||||||
@@ -49,9 +49,11 @@ import ImageSource from '../source/Image.js';
|
|||||||
*/
|
*/
|
||||||
class ImageCanvasSource extends ImageSource {
|
class ImageCanvasSource extends ImageSource {
|
||||||
/**
|
/**
|
||||||
* @param {Options=} options ImageCanvas options.
|
* @param {Options=} opt_options ImageCanvas options.
|
||||||
*/
|
*/
|
||||||
constructor(options) {
|
constructor(opt_options) {
|
||||||
|
|
||||||
|
const options = opt_options || /** @type {Options} */ ({});
|
||||||
|
|
||||||
super({
|
super({
|
||||||
attributions: options.attributions,
|
attributions: options.attributions,
|
||||||
@@ -108,8 +110,8 @@ class ImageCanvasSource extends ImageSource {
|
|||||||
const height = getHeight(extent) / resolution;
|
const height = getHeight(extent) / resolution;
|
||||||
const size = [width * pixelRatio, height * pixelRatio];
|
const size = [width * pixelRatio, height * pixelRatio];
|
||||||
|
|
||||||
const canvasElement = this.canvasFunction_(
|
const canvasElement = this.canvasFunction_.call(
|
||||||
extent, resolution, pixelRatio, size, projection);
|
this, extent, resolution, pixelRatio, size, projection);
|
||||||
if (canvasElement) {
|
if (canvasElement) {
|
||||||
canvas = new ImageCanvas(extent, resolution, pixelRatio, canvasElement);
|
canvas = new ImageCanvas(extent, resolution, pixelRatio, canvasElement);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user