leafpop icon indicating copy to clipboard operation
leafpop copied to clipboard

Opening multiple popups simultaneously

Open ploner opened this issue 5 years ago • 8 comments

Hi, this is a nice, useful a package. Love it. However, I tried to open multiple popups at the same time, and could not get a solution. On https://stackoverflow.com/questions/38957585/how-can-i-open-multiple-popups-in-leaflet-marker-at-a-time there are some hints, but work directly on the map instead of the layer. Any idea how to solve this? Thx, M

ploner avatar Apr 01 '20 07:04 ploner

Just to understand your query properly, do you want to

a) prevent closing of open popups when opening another one, or b) open several popups at the same time when clicking a marker (for e.g. all markers that belong to the same group)?

tim-salabim avatar Apr 01 '20 08:04 tim-salabim

Actually I want to open all popups (e.g. on app start) by code, for all the markers. Then, on-demand, the user could close some - but that's a feature with lower priority.

ploner avatar Apr 01 '20 11:04 ploner

Like this:

library(mapview) # for the data
library(leaflet)
library(leafpop)

brew = breweries[1:2, ]

leaflet() %>%
  addTiles() %>%
  addCircleMarkers(
    data = brew
  ) %>%
  addPopups(
    lat = st_coordinates(brew)[, 2] 
    , lng = st_coordinates(brew)[, 1]
    , popup = popupTable(brew)
    , options = popupOptions(closeOnClick = FALSE)
  )

?

tim-salabim avatar Apr 01 '20 14:04 tim-salabim

The 1st popup still closes when I open another popup. I have to apply these 2 options:

popupOptions(closeOnClick = FALSE, autoClose=FALSE)

but autoClose does not work :(

ploner avatar Apr 01 '20 17:04 ploner

Do you have some reproducible code?

tim-salabim avatar May 01 '21 10:05 tim-salabim

Hi-

Thank you so much for this package- it's really great. I have 2 questions that are similar to this:

  1. I would like to cause 2 different images to pop up either stacked or side by side. Is this possible?
  2. Alternatively I am interested in adding a dropdown menu to a pop-up that I could then select different images from. Is there any chance that functionality is supported in this package?

Thanks again!

O

DEQorudlof avatar Jul 27 '21 00:07 DEQorudlof

Hi @DEQorudlof

  1. Yes that is possible if you install from github, see e.g. https://github.com/r-spatial/leafpop/issues/19#issuecomment-846376609
  2. That is currently not possible and I am not planning on adding it anytime soon. For that you would need proper JS knowledge, which I don't have

HTH

tim-salabim avatar Jul 27 '21 06:07 tim-salabim

Hi Tim-

Thanks for the quick response! I wonder if you could take a quick look at the code that I'm using that is not doing this for me. I don't have a reprex so if there's nothing you could see without one I understand, but maybe you'll see some obvious solution that I don't see:

leaf <-leaflet() %>% addTiles() %>% addMarkers(data = dat2, group = "SNc",popup = ~paste("Facility: ",Facility, ") ) %>% addPopupImages(image = paste0(dat2$SNc,".png"), group = "SNc", width=200, height=200)%>% addPopupImages(image = paste0(dat2$SNc,"._d.png"), group = "SNc", width=300, height=300)

I keep getting a pandoc error: Knitting issue: pandoc.exe: C:\Users\orudlof\AppData\Local\Temp\Rtmporiytk\imagesb6e259\10029.png: openBinaryFile: does not exist (No such file or directory) Error: pandoc document conversion failed with error 1 Execution halted

I don't suppose you have any idea why that would happen? The funny thing is I don't get the error when I do one or the other, it only occurs when I do both.

DEQorudlof avatar Jul 27 '21 20:07 DEQorudlof