Mides
Mides

Reputation: 39

How to disable events

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 ?

enter image description here enter image description here

Upvotes: 1

Views: 1392

Answers (2)

Mides
Mides

Reputation: 39

var container = document.getElementById('popup');    
...
container.onmousemove = function(evt) {
    evt.stopPropagation();
    tooltip.innerHTML = "";
};  

Upvotes: 0

Alexandre Dubé
Alexandre Dubé

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 openlayers

What you could do is this: do nothing when evt.originalEvent.target is not the OpenLayers' viewport.

Update 2016-04-13

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

Related Questions