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.

Marker Popup (Info Window) Remains Open After Marker Is Removed From Map

See original GitHub issue

Issue Type

[ x ] Bug

Description and/or steps/code to reproduce the problem

  1. Create a Marker on the map and click on it to open its info window
  2. With the info window open, remove that Marker from the map and redraw the map (for example, as the result of a search that is only showing a subset of all markers)
  3. The Marker is removed but the info window remains open and visible

I tried overriding several onRemove type methods to no avail, although this should really be the default behavior. A workaround that we have in place is to close all open info windows when the map overlays are updated, but this shouldn’t be necessary.

FWIW, we are overriding onMarkerClickListener (to avoid the default map recentering that accompanies the info window being opened), but I don’t see why that would cause this problem.

Environment

Latest version of osmdroid, Android SDK 33, testing in the Android emulator.

If it’s a bug, version(s) of android this affects:

Not sure. Only tested on one so far.

Version of osmdroid the issue relates to:

6.1.2

Thanks for all the hard work on osmdroid! This is a really great library.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
MKergallcommented, Oct 23, 2022

It is not based on use cases - it’s a drawback of the implementation method. And it’s clearly an issue. InfoWindow.closeAllInfoWindowsOn is just an awful workaround. But I also know that it’s clearly “extra work” to achieve the non-strange result.

Have a look at #397 :
“Marker should have a factory-method to create an InfoWindow on demand instead of containing a precreated InfoWindow . The object “InfoWindow” should only exist as long as the popup-bubble is opend.”

By the way, this is not specific to Marker, but to all OverlayWithIW.

Ideas and PRs are welcomed, but keep in mind that a rework on this class may have serious impacts on users who implemented subclasses of Markers, made customized infowindows, etc.

1reaction
gchallencommented, Oct 21, 2022

Yes, strange, but it is doable!

Sure, but what’s strange shouldn’t be the default behavior 😄. I think it’s reasonable to expect that the popup is removed with the marker. If you want to change that behavior for some strange reason, then having a way to disable that would be fine. But ideally it shouldn’t be extra work to achieve the non-strange result.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I remove an InfoWindow when the Marker is removed?
But if I click on a marker, open an InfoWindow , and then click on a check box to remove the markers of...
Read more >
Info Window | Maps JavaScript API - Google Developers
Opens this InfoWindow on the given map. Optionally, an InfoWindow can be associated with an anchor. In the core API, the only anchor...
Read more >
Binding problem in infoWindow with Marker - Google Groups
As expected, the InfoWindow opened. 5) Remove the marker from the map through Marker.setMap(null) 6) Well, InfoWindow is still opening there .
Read more >
Google Maps API V3: Open (Show) only one InfoWindow at a ...
The solution to this problem is fairly simple. You just need to create one instance of InfoWindow object so that the same InfoWindow...
Read more >
Google Maps JavaScript API Episode 4 - Info Windows
In this video series, we will be learning about the Google Maps JavaScript API. We will learn everything about the Google Maps JavaScript ......
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