Add ol.source.ImageVector#forEachFeatureAtPixel

This commit is contained in:
Éric Lemoine
2014-01-13 11:42:25 +01:00
parent 4cd2a75900
commit 849e50517c

View File

@@ -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,34 @@ 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.
*/
function(geometry, data) {
var feature = /** @type {ol.Feature} */ (data);
return callback(feature);
});
}
};
/**
* @param {ol.Coordinate} center Center.
* @param {number} resolution Resolution.