Add renderBuffer option for ol.source.ImageVector

This commit is contained in:
Andreas Hocevar
2016-07-13 14:23:41 +02:00
parent 79d8660ded
commit a64e3c1d3e
2 changed files with 19 additions and 1 deletions

View File

@@ -4970,6 +4970,7 @@ olx.source.ImageCanvasOptions.prototype.state;
* logo: (string|olx.LogoOptions|undefined), * logo: (string|olx.LogoOptions|undefined),
* projection: ol.ProjectionLike, * projection: ol.ProjectionLike,
* ratio: (number|undefined), * ratio: (number|undefined),
* renderBuffer: (number|undefined),
* resolutions: (Array.<number>|undefined), * resolutions: (Array.<number>|undefined),
* source: ol.source.Vector, * source: ol.source.Vector,
* style: (ol.style.Style|Array.<ol.style.Style>|ol.StyleFunction|undefined)}} * style: (ol.style.Style|Array.<ol.style.Style>|ol.StyleFunction|undefined)}}
@@ -5011,6 +5012,17 @@ olx.source.ImageVectorOptions.prototype.projection;
olx.source.ImageVectorOptions.prototype.ratio; olx.source.ImageVectorOptions.prototype.ratio;
/**
* The buffer around the viewport extent used by the renderer when getting
* features from the vector source for the rendering or hit-detection.
* Recommended value: the size of the largest symbol, line width or label.
* Default is 100 pixels.
* @type {number|undefined}
* @api
*/
olx.source.ImageVectorOptions.prototype.renderBuffer;
/** /**
* Resolutions. If specified, new canvases will be created for these resolutions * Resolutions. If specified, new canvases will be created for these resolutions
* only. * only.

View File

@@ -56,6 +56,12 @@ ol.source.ImageVector = function(options) {
*/ */
this.canvasSize_ = [0, 0]; this.canvasSize_ = [0, 0];
/**
* @private
* @type {number}
*/
this.renderBuffer_ = options.renderBuffer == undefined ? 100 : options.renderBuffer;
/** /**
* @private * @private
* @type {ol.render.canvas.ReplayGroup} * @type {ol.render.canvas.ReplayGroup}
@@ -108,7 +114,7 @@ ol.source.ImageVector.prototype.canvasFunctionInternal_ = function(extent, resol
var replayGroup = new ol.render.canvas.ReplayGroup( var replayGroup = new ol.render.canvas.ReplayGroup(
ol.renderer.vector.getTolerance(resolution, pixelRatio), extent, ol.renderer.vector.getTolerance(resolution, pixelRatio), extent,
resolution); resolution, this.renderBuffer_);
this.source_.loadFeatures(extent, resolution, projection); this.source_.loadFeatures(extent, resolution, projection);