r-spatial / leafpop

Include Tables, Images and Graphs in Leaflet Popups
Other
113 stars 15 forks source link

Adding two sets of popup graphs results in broken popup #16

Closed barryrowlingson closed 4 years ago

barryrowlingson commented 4 years ago

If I have two layers in a leaflet map and try to have two sets of popup graphs, then one of them is broken. Example:

test <- function(){
    set.seed(1)
    map1 = st_as_sf(data.frame(lat=runif(5),long=runif(5),x=runif(1:5),y=rnorm(1:5)),coords=1:2,crs=4326)
    grobs1 = lapply(1:5, function(i){ggplot(map1, aes(x=x,y=y)) + geom_line()})
    map2 = st_as_sf(data.frame(lat=runif(5),long=runif(5),x=runif(1:5),y=rnorm(1:5)),coords=1:2,crs=4326)
    grobs2 = lapply(1:5, function(i){ggplot(map2, aes(x=x,y=y)) + geom_line()})
    leaflet() %>%
        addMarkers(data=map1, group="one") %>%
        addPopupGraphs(grobs1, group="one") %>%
        addMarkers(data=map2, group="two") %>%
        addPopupGraphs(grobs2, group="two")
}

This creates two sets of 5 points, and two lists of grobs of length 5. The resulting leaflet map, viewed straight (not using shiny) in the browser, has five points that do popup the graph and five that don't, giving a broken image icon.

Trying saveWidget gives:

> saveWidget(test(),file="/tmp/w.html")
File w_files/image-0.0.1/file73a0133bbafc.png not found in resource path
Error: pandoc document conversion failed with error 99

which I suspect is the same issue - the image file not found by pandoc here is the image not being shown in the leaflet popup map.

leafpop version 0.05 htmlwidgets version 1.5.1

need any more info?

tim-salabim commented 4 years ago

Thanks for reporting, should be fixed now.