Reputation: 39
How to disable or hide the events of a feature that are under an overlay? The event "map.on ( 'SingleClick'" is well off but not the "event map.on (' pointermove'" of the marker below the overlay.
Do you have an idea ?
Upvotes: 1
Views: 1392
Reputation: 39
var container = document.getElementById('popup');
...
container.onmousemove = function(evt) {
evt.stopPropagation();
tooltip.innerHTML = "";
};
Upvotes: 0
Reputation: 2829
Here's something you could do. In the method called when the pointermove
event occurs, you could check the values of the following properties:
evt.originalEvent.target
- that is always equal to the dom element being the target of the event. For example, while mouse hovering the popup it can be equal to <div id="popup-content">...</div>
evt.originalEvent.currentTarget
- that will always be equal to the viewport div of openlayersWhat you could do is this: do nothing when evt.originalEvent.target
is not the OpenLayers' viewport.
I had to do something quite similar. I had an overlay in a map and I wanted to prevent the pointermove
from occurring below it. Here's what I did:
var target = evt.originalEvent.target;
if ($(this.getElement()).has(target)) {
evt.coordinate = [Infinity, Infinity];
evt.pixel = [Infinity, Infinity];
}
In the above, this
represents the ol.Overlay
object. The idea is to override the coordinate and pixel properties of the event, which makes the rest of the interactions act as I wanted: do nothing.
Upvotes: 1