Merge pull request #1504 from elemoine/vector-api-image-vector-hit-detection
[vector-api] Vector image hit detection
This commit is contained in:
@@ -73,6 +73,12 @@ ol.source.ImageVector = function(options) {
|
||||
*/
|
||||
this.canvasSize_ = [0, 0];
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.render.canvas.ReplayGroup}
|
||||
*/
|
||||
this.replayGroup_ = null;
|
||||
|
||||
goog.base(this, {
|
||||
attributions: options.attributions,
|
||||
canvasFunction: goog.bind(this.canvasFunctionInternal_, this),
|
||||
@@ -135,10 +141,35 @@ ol.source.ImageVector.prototype.canvasFunctionInternal_ =
|
||||
replayGroup.replay(this.canvasContext_, extent, pixelRatio, transform,
|
||||
goog.functions.TRUE);
|
||||
|
||||
this.replayGroup_ = replayGroup;
|
||||
|
||||
return this.canvasElement_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.source.ImageVector.prototype.forEachFeatureAtPixel =
|
||||
function(extent, resolution, rotation, coordinate, callback) {
|
||||
if (goog.isNull(this.replayGroup_)) {
|
||||
return undefined;
|
||||
} else {
|
||||
return this.replayGroup_.forEachGeometryAtPixel(
|
||||
extent, resolution, 0, coordinate, goog.functions.TRUE,
|
||||
/**
|
||||
* @param {ol.geom.Geometry} geometry Geometry.
|
||||
* @param {Object} data Data.
|
||||
* @return {?} Callback result.
|
||||
*/
|
||||
function(geometry, data) {
|
||||
var feature = /** @type {ol.Feature} */ (data);
|
||||
return callback(feature);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Coordinate} center Center.
|
||||
* @param {number} resolution Resolution.
|
||||
|
||||
@@ -93,6 +93,19 @@ ol.source.Source.prototype.dispatchChangeEvent = function() {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Extent} extent Extent.
|
||||
* @param {number} resolution Resolution.
|
||||
* @param {number} rotation Rotation.
|
||||
* @param {ol.Coordinate} coordinate Coordinate.
|
||||
* @param {function(ol.Feature): T} callback Feature callback.
|
||||
* @return {T|undefined} Callback result.
|
||||
* @template T
|
||||
*/
|
||||
ol.source.Source.prototype.forEachFeatureAtPixel =
|
||||
goog.nullFunction;
|
||||
|
||||
|
||||
/**
|
||||
* @return {Array.<ol.Attribution>} Attributions.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user