Use x of the real world in forEachFeatureAtCoordinate
This commit is contained in:
@@ -9,6 +9,7 @@ goog.require('goog.events.EventType');
|
||||
goog.require('goog.functions');
|
||||
goog.require('goog.object');
|
||||
goog.require('goog.vec.Mat4');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.layer.Layer');
|
||||
goog.require('ol.renderer.Layer');
|
||||
goog.require('ol.style.IconImageCache');
|
||||
@@ -136,23 +137,44 @@ ol.renderer.Map.prototype.forEachFeatureAtCoordinate =
|
||||
var viewState = frameState.viewState;
|
||||
var viewResolution = viewState.resolution;
|
||||
var viewRotation = viewState.rotation;
|
||||
|
||||
/** @type {Object.<string, boolean>} */
|
||||
var features = {};
|
||||
|
||||
/**
|
||||
* @param {ol.Feature} feature Feature.
|
||||
* @return {?} Callback result.
|
||||
*/
|
||||
function forEachFeatureAtCoordinate(feature) {
|
||||
goog.asserts.assert(goog.isDef(feature), 'received a feature');
|
||||
var key = goog.getUid(feature).toString();
|
||||
if (!(key in features)) {
|
||||
features[key] = true;
|
||||
return callback.call(thisArg, feature, null);
|
||||
}
|
||||
}
|
||||
|
||||
var projection = viewState.projection;
|
||||
|
||||
var translatedX;
|
||||
if (projection.isGlobal()) {
|
||||
var projectionExtent = projection.getExtent();
|
||||
var worldWidth = ol.extent.getWidth(projectionExtent);
|
||||
var x = coordinate[0];
|
||||
if (x < projectionExtent[0] || x > projectionExtent[2]) {
|
||||
var worldsAway = Math.ceil((projectionExtent[0] - x) / worldWidth);
|
||||
translatedX = x + worldWidth * worldsAway;
|
||||
}
|
||||
}
|
||||
|
||||
if (!goog.isNull(this.replayGroup)) {
|
||||
/** @type {Object.<string, boolean>} */
|
||||
var features = {};
|
||||
result = this.replayGroup.forEachFeatureAtCoordinate(coordinate,
|
||||
viewResolution, viewRotation, {},
|
||||
/**
|
||||
* @param {ol.Feature} feature Feature.
|
||||
* @return {?} Callback result.
|
||||
*/
|
||||
function(feature) {
|
||||
goog.asserts.assert(goog.isDef(feature), 'received a feature');
|
||||
var key = goog.getUid(feature).toString();
|
||||
if (!(key in features)) {
|
||||
features[key] = true;
|
||||
return callback.call(thisArg, feature, null);
|
||||
}
|
||||
});
|
||||
viewResolution, viewRotation, {}, forEachFeatureAtCoordinate);
|
||||
if (!result && goog.isDef(translatedX)) {
|
||||
result = this.replayGroup.forEachFeatureAtCoordinate(
|
||||
[translatedX, coordinate[1]],
|
||||
viewResolution, viewRotation, {}, forEachFeatureAtCoordinate);
|
||||
}
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
@@ -168,6 +190,10 @@ ol.renderer.Map.prototype.forEachFeatureAtCoordinate =
|
||||
var layerRenderer = this.getLayerRenderer(layer);
|
||||
result = layerRenderer.forEachFeatureAtCoordinate(
|
||||
coordinate, frameState, callback, thisArg);
|
||||
if (!result && goog.isDef(translatedX)) {
|
||||
result = layerRenderer.forEachFeatureAtCoordinate(
|
||||
[translatedX, coordinate[1]], frameState, callback, thisArg);
|
||||
}
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user