question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MapBrowserEventHandler needs to be destroyed for listeners to be unregistered

See original GitHub issue

Describe the bug MouseWheelZoom.conditionInternal_ throws errors when the map target is null due to the hasAttribute check. I see this is changed on master but I believe this bug will still exist (https://github.com/openlayers/openlayers/commit/2cac6c4f39521470a899f1c6338aa47baea05392#diff-a08a90960184e04e1b7384a480a81d6a).

To Reproduce Steps to reproduce the behavior:

  1. Go to https://codesandbox.io/s/react-openlayers-xni5f?file=/src/App.js which contains a simple map example reloading every 5s and setting the previous map target to null (myMap.setTarget(null);)
  2. Click on the map to drag but don’t release for 5s.
  3. Next mouse movements will trigger an error: image image

What I’ve found so far is

  • Events need a map target or they crash
  • Events are not deregisterd without map.dispose which propagates to disposeInternal of MapBrowserEventHandler where it unlistens avoiding the events to be called.

Expected behavior I am not sure which solution is preferable:

Let me know what you prefer @tschaub

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ahocevarcommented, Jul 7, 2020

@EvertEt You are right. But we also want to handle the case where users change the map target, right? disposeInternal won’t be called in that case. So the best solution is to unregister all those listeners when the target is unset, and register them again when the target is set.

That said, I’m planning to release v6.4 this week. Do you think you’d be able to create a pull request? If not let me know, then I’ll take this on.

0reactions
EvertEtcommented, Jul 9, 2020

image We have another similar error reported in MouseWheelZoom which doesn’t seem fixed by using map.dispose. We haven’t had time to look into it any further. Just posting this here in case someone else will look at creating a PR

Read more comments on GitHub >

github_iconTop Results From Across the Web

What are the possible listeners and event types for an ...
Listeners can be registered and unregistered on all objects descending from ol.Observable. All event instances have a target property, ...
Read more >
Overlay - Element events (click) pass through to Map #6948
I have a popup in React made as an Overlay. ... MapBrowserEventHandler needs to be destroyed for listeners to be unregistered #11231.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found