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

Embedding Leaflet objects as popups doesn't work when generating an HTML file #33

Open
f8l5h9 opened this issue Sep 30, 2024 · 2 comments

Comments

@f8l5h9
Copy link

f8l5h9 commented Sep 30, 2024

I am using popupGraph to include popups in a Leaflet object by passing a list of other Leaflet objects to generate an HTML file. Below is a reproducible example.
image

Everything works perfectly in my local R environment, but when I open the HTML file in a browser, it cannot find the Leaflet objects stored in the temporary folder. See https://emods.es/leafpop_problem.html
Do you have any suggestions on how I can embed the Leaflet objects as popups so that they are included in the final HTML output?

image

title: "leafpop"
author: ""
output: html_document

library(leaflet)
library(leafpop)
library(dplyr)

cities <- data.frame(
  city = c("Sevilla", "Cartagena", "Valencia"),
  lat = c(37.389092, 37.625683, 39.469907),
  lon = c(-5.984459, -1.001400, -0.376288)
)

mymap <- list()
for (i in 1:3){
mymap[[i]] <- leaflet() %>%
  addTiles() %>%
  setView(lng = cities[i,3], lat = cities[i,2], zoom = 16) 
}

leaflet() %>% 
  addTiles() %>%
  addMarkers(data=cities,~lon ,~lat,
                 popup = ~popupGraph(mymap))
@tim-salabim
Copy link
Member

Thanks, this has been on my plate for a long time. For technical reasons from the htmlwidgets package, the way this is currently implemented means the popup htmls are saved to a location one level above where the map html is saved. If you keep this structure wherever you want to host this map, the popups should work as expected.
I have been meaning to provide a proper method that will embed the popups in the map html, but haven't found much time (and frankly forgot about it). I hope to get this working soon, as I already have a scaffold for it

@SamAllwood
Copy link

I think I have the same issue trying to use popups from leafpop inside a Shiny app? The output is an html and the popup images are not rendered, even though they are when creating the leaflet map outside the Shiny function.

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