Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opening multiple popups simultaneously #13

Open
ploner opened this issue Apr 1, 2020 · 8 comments
Open

Opening multiple popups simultaneously #13

ploner opened this issue Apr 1, 2020 · 8 comments

Comments

@ploner
Copy link

ploner commented Apr 1, 2020

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

@tim-salabim
Copy link
Member

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)?

@ploner
Copy link
Author

ploner commented Apr 1, 2020

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.

@tim-salabim
Copy link
Member

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)
  )

?

@ploner
Copy link
Author

ploner commented Apr 1, 2020

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 :(

@tim-salabim
Copy link
Member

Do you have some reproducible code?

@DEQorudlof
Copy link

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

@tim-salabim
Copy link
Member

Hi @DEQorudlof

  1. Yes that is possible if you install from github, see e.g. Can't add multiple popup images to addPopupImages from local source #19 (comment)
  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

@DEQorudlof
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants