Skip to content

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

@f8l5h9

Description

@f8l5h9

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions