diff --git a/src/ol/extent.js b/src/ol/extent.js index 1f54e4bf65..f556bec0f6 100644 --- a/src/ol/extent.js +++ b/src/ol/extent.js @@ -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.} 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]; }; diff --git a/src/ol/renderer/canvas/canvasvectorlayerrenderer.js b/src/ol/renderer/canvas/canvasvectorlayerrenderer.js index ba4c2b218e..7a076406d1 100644 --- a/src/ol/renderer/canvas/canvasvectorlayerrenderer.js +++ b/src/ol/renderer/canvas/canvasvectorlayerrenderer.js @@ -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)) { - result.push(candidate); + 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