From 15fd9f7662a253aaa5adf8c793dc7ad55fd4018d Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Mon, 2 Dec 2013 16:25:17 +0100 Subject: [PATCH] Break out of forEachFeatureAtPixel as soon as hit detected in icon example --- examples/icon.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/examples/icon.js b/examples/icon.js index 97c42b04d2..82e1d5ae53 100644 --- a/examples/icon.js +++ b/examples/icon.js @@ -68,9 +68,8 @@ map.addOverlay(popup); // display popup on click map.on('singleclick', function(evt) { - var feature; - map.forEachFeatureAtPixel(evt.getPixel(), function(f) { - feature = f; + var feature = map.forEachFeatureAtPixel(evt.getPixel(), function(feature) { + return feature; }); if (feature) { var geometry = feature.getGeometry(); @@ -90,9 +89,8 @@ map.on('singleclick', function(evt) { // change mouse cursor when over marker $(map.getViewport()).on('mousemove', function(e) { var pixel = map.getEventPixel(e.originalEvent); - var hit = false; - map.forEachFeatureAtPixel(pixel, function(feature) { - hit = true; + var hit = map.forEachFeatureAtPixel(pixel, function(feature) { + return true; }); if (hit) { map.getTarget().style.cursor = 'pointer';