Break out of forEachFeatureAtPixel as soon as hit detected in icon example
This commit is contained in:
@@ -68,9 +68,8 @@ map.addOverlay(popup);
|
|||||||
|
|
||||||
// display popup on click
|
// display popup on click
|
||||||
map.on('singleclick', function(evt) {
|
map.on('singleclick', function(evt) {
|
||||||
var feature;
|
var feature = map.forEachFeatureAtPixel(evt.getPixel(), function(feature) {
|
||||||
map.forEachFeatureAtPixel(evt.getPixel(), function(f) {
|
return feature;
|
||||||
feature = f;
|
|
||||||
});
|
});
|
||||||
if (feature) {
|
if (feature) {
|
||||||
var geometry = feature.getGeometry();
|
var geometry = feature.getGeometry();
|
||||||
@@ -90,9 +89,8 @@ map.on('singleclick', function(evt) {
|
|||||||
// change mouse cursor when over marker
|
// change mouse cursor when over marker
|
||||||
$(map.getViewport()).on('mousemove', function(e) {
|
$(map.getViewport()).on('mousemove', function(e) {
|
||||||
var pixel = map.getEventPixel(e.originalEvent);
|
var pixel = map.getEventPixel(e.originalEvent);
|
||||||
var hit = false;
|
var hit = map.forEachFeatureAtPixel(pixel, function(feature) {
|
||||||
map.forEachFeatureAtPixel(pixel, function(feature) {
|
return true;
|
||||||
hit = true;
|
|
||||||
});
|
});
|
||||||
if (hit) {
|
if (hit) {
|
||||||
map.getTarget().style.cursor = 'pointer';
|
map.getTarget().style.cursor = 'pointer';
|
||||||
|
|||||||
Reference in New Issue
Block a user