Do not change ol.extent.containsCoordinate
This commit is contained in:
@@ -57,26 +57,15 @@ ol.extent.boundingExtentXYs_ = function(xs, ys, opt_extent) {
|
||||
|
||||
|
||||
/**
|
||||
* Checks if (one of) the passed coordinate(s) is contained or on the edge
|
||||
* of the extent.
|
||||
* Checks if the passed coordinate is contained or on the edge of the extent.
|
||||
*
|
||||
* @param {ol.Extent} extent Extent.
|
||||
* @param {ol.Coordinate|Array.<ol.Coordinate>} coordinates Coordinate(s).
|
||||
* @param {ol.Coordinate} coordinates Coordinate.
|
||||
* @return {boolean} Contains.
|
||||
*/
|
||||
ol.extent.containsCoordinate = function(extent, coordinates) {
|
||||
coordinates = goog.isArray(coordinates[0]) ? coordinates : [coordinates];
|
||||
var contains = false,
|
||||
coordinate, i;
|
||||
for (i = coordinates.length - 1; i >= 0; --i) {
|
||||
coordinate = coordinates[i];
|
||||
if (extent[0] <= coordinate[0] && coordinate[0] <= extent[1] &&
|
||||
extent[2] <= coordinate[1] && coordinate[1] <= extent[3]) {
|
||||
contains = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return contains;
|
||||
ol.extent.containsCoordinate = function(extent, coordinate) {
|
||||
return extent[0] <= coordinate[0] && coordinate[0] <= extent[1] &&
|
||||
extent[2] <= coordinate[1] && coordinate[1] <= extent[3];
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -238,8 +238,14 @@ ol.renderer.canvas.VectorLayer.prototype.getFeatureInfoForPixel =
|
||||
[[location[0] - halfWidth, location[1] - halfHeight],
|
||||
[location[0] + halfWidth, location[1] + halfHeight]]);
|
||||
coordinates = geom.getCoordinates();
|
||||
if (ol.extent.containsCoordinate(symbolBounds, coordinates)) {
|
||||
if (!goog.isArray(coordinates[0])) {
|
||||
coordinates = [coordinates];
|
||||
}
|
||||
for (j = coordinates.length - 1; j >= 0; --j) {
|
||||
if (ol.extent.containsCoordinate(symbolBounds, coordinates[j])) {
|
||||
result.push(candidate);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (goog.isFunction(geom.containsCoordinate)) {
|
||||
// For polygons, check if the pixel location is inside the polygon
|
||||
|
||||
Reference in New Issue
Block a user