I am attempting to create a mouse hover event using the following method taken from the official OL3 examples page:
http://openlayers.org/en/latest/examples/earthquake-clusters.html
I need to trigger the action only when hovering over a particular layer. Having consulted the official documentation I discovered that you can use a layer filter function with hasFeatureAtPixel, but it doesn't appear to be working.
map.on('pointermove', function(evt) {
if (evt.dragging) {
return;
}
var pixel = map.getEventPixel(evt.originalEvent);
var hit = map.hasFeatureAtPixel(pixel, function(feature, layer) {
console.log(layer);
console.log(feature);
});
});
The console.log calls result in feature objects being given in the console, but no layer objects, these are returned as 'undefined'. It is the layer objects which I need to test whether the layer is the correct one.
Any ideas why this isn't working?