0

What is the best way to add a 'featureover' event on top of an ol.interaction.Modify ? At the map or layer level, this event is masked by the interaction.

The 'modifystart' event is fired when the feature is actually modified, that is after it is selected, and I'd like to know when the mouse is over the feature.

  • I think there isn't any featureover event at all in OL3? For that purpose, you can track mouse position with map.on('pointermove', ... and use map.forEachFeatureAtPixel to detect features. Here's example: openlayers.org/en/v3.13.0/examples/kml.html – user1702401 Feb 2 '16 at 18:13
1

My bad, I stumbled on an OL2 example with featureover and didn't pay attention. From the KML example given in the above comment, the code below works along with a ol.interaction.Modify :

map.on('pointermove', function(evt) {
    if (evt.dragging) {
        return;
    }
    var pixel = map.getEventPixel(evt.originalEvent);
    map.forEachFeatureAtPixel(pixel, function(feature) {
        // your stuff here
    });
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.