Add imageRatio option for VectorImage layers

This commit is contained in:
Frederic Junod
2018-11-13 19:05:21 +01:00
parent 5951e147c0
commit e66a84c897
4 changed files with 69 additions and 2 deletions

View File

@@ -2,10 +2,13 @@
* @module ol/layer/VectorImage
*/
import BaseVectorLayer from './BaseVector.js';
import {assign} from '../obj.js';
import CanvasVectorImageLayerRenderer from '../renderer/canvas/VectorImageLayer.js';
/**
* @typedef {import("./BaseVector.js").Options} Options
* @property {number} [imageRatio=1] Ratio by which the rendered extent should be larger than the
* viewport extent A larger ratio avoids cut images during panning, but will cause a decrease in performance.
*/
@@ -23,7 +26,25 @@ class VectorImageLayer extends BaseVectorLayer {
* @param {Options=} opt_options Options.
*/
constructor(opt_options) {
const options = opt_options ? opt_options : /** @type {Options} */ ({});
const baseOptions = assign({}, options);
delete baseOptions.imageRatio;
super(opt_options);
/**
* @type {number}
* @private
*/
this.imageRatio_ = options.imageRatio !== undefined ? options.imageRatio : 1;
}
/**
* @return {number} Ratio between rendered extent size and viewport extent size.
*/
getImageRatio() {
return this.imageRatio_;
}
/**