Add layer to forEachFeatureAtPixel callbacks in examples

This commit is contained in:
Tom Payne
2013-12-02 16:46:24 +01:00
parent e9267e401c
commit 5acc673c68
3 changed files with 7 additions and 6 deletions

View File

@@ -68,9 +68,10 @@ map.addOverlay(popup);
// display popup on click // display popup on click
map.on('singleclick', function(evt) { map.on('singleclick', function(evt) {
var feature = map.forEachFeatureAtPixel(evt.getPixel(), function(feature) { var feature = map.forEachFeatureAtPixel(evt.getPixel(),
return feature; function(feature, layer) {
}); return feature;
});
if (feature) { if (feature) {
var geometry = feature.getGeometry(); var geometry = feature.getGeometry();
var coord = geometry.getCoordinates(); var coord = geometry.getCoordinates();
@@ -89,7 +90,7 @@ 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 = map.forEachFeatureAtPixel(pixel, function(feature) { var hit = map.forEachFeatureAtPixel(pixel, function(feature, layer) {
return true; return true;
}); });
if (hit) { if (hit) {

View File

@@ -64,7 +64,7 @@ var map = new ol.Map({
$(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 = map.forEachFeatureAtPixel(pixel, function(feature) { var hit = map.forEachFeatureAtPixel(pixel, function(feature, layer) {
return true; return true;
}); });

View File

@@ -59,7 +59,7 @@ var highlight;
var displayFeatureInfo = function(pixel) { var displayFeatureInfo = function(pixel) {
var oldHighlight = highlight; var oldHighlight = highlight;
var feature = map.forEachFeatureAtPixel(pixel, function(feature) { var feature = map.forEachFeatureAtPixel(pixel, function(feature, layer) {
return feature; return feature;
}); });