How can a popup stay open when clicking on another?
The MWE below show a popup when I click on the markers. Good. But when I click on a second marker I don't want the first popup to disappear. It should only disapear when clicking the close [x]. No popups should be visible before clicking on the markers.
library(leaflet)
the.points <- data.frame(latitude=c(63.136353,63.132935,63.128051),
longitude=c(21.928023,21.962601,21.893444),
text=c("One point", "A second point", "The third point"))
p <- leaflet(the.points)
p <- addTiles(p)
p <- addMarkers(p, lng=~longitude, lat=~latitude, popup=~text)
p
I tried with addPopups too, but they are all visible by default. If that can be changed it would be good (not sure how).
Was struggling with the same thing, finally this worked for me:
leaflet() %>% addTiles() %>%
addMarkers(
lng = -118.456554, lat = 34.085,
popup = "One popup",
popupOptions = popupOptions(autoClose = FALSE, closeOnClick = FALSE)) %>%
addMarkers(
lng = -118.456554, lat = 34.065,
popup = "Another popup",
popupOptions = popupOptions(autoClose = FALSE, closeOnClick = FALSE))
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With