Leaflet: autoClose isn't working?

Created on 17 Aug 2017  Â·  6Comments  Â·  Source: Leaflet/Leaflet

How to reproduce

  • Leaflet version I'm using: 1.1.0
  • Browser (with version) I'm using: Chrome Version 60.0.3112.90 (Official Build)
  • OS/Platform (with version) I'm using: Ubuntu 16.04
  • Having 2 (or more) markers on map
  • Bind popups to them, with option autoClose : false

What behaviour I'm expecting and which behaviour I'm seeing

Documentation says this:

autoClose:

Set it to false if you want to override the default behavior of the popup closing when another popup is opened.

so i'm expecting to click on another marker and the first popup not closing, but it closes.

Minimal example reproducing the issue

jsfiddle

Most helpful comment

I figured it out.
The first popup is not closing because the second one opens, it is closing because the map is being clicked.

To fix, you need to set additional option to false:

{
    autoClose:false,
    closeOnClick:false
}

All 6 comments

I figured it out.
The first popup is not closing because the second one opens, it is closing because the map is being clicked.

To fix, you need to set additional option to false:

{
    autoClose:false,
    closeOnClick:false
}

https://jsfiddle.net/6d5c26u3/9/
I'm clicking on both markers and the popups are closing.

I don't know what

closing when another popup is opened.

has to do with clicking on map.

https://jsfiddle.net/6d5c26u3/11/

It's BECAUSE you're clicking on the map when you click the marker.

So there's no way to have that behaviour when clicking on marker, but when you really click on the map close all markers (default behaviour) ?

Edit: how's that if by default bubblingMouseEvents

When true, a mouse event on this marker will trigger the same event on the map (unless L.DomEvent.stopPropagation is used).

is false ?!?

Can you re-open the issue? Or at least tell me how i can have that behavior on markers ( popup don't close when clicking on another marker ) and still close them when clicking on map.

@rogeriocsilva you can set the map's closePopupOnClick: false. https://jsfiddle.net/85a3frb3/

Was this page helpful?
0 / 5 - 0 ratings