Add layer to forEachFeatureAtPixel callbacks in examples
This commit is contained in:
@@ -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) {
|
||||||
|
|||||||
@@ -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;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user