Leaflet not rendering in dynamically generated R markdown html knitr

后端 未结 2 1420
说谎
说谎 2021-01-16 16:23

I\'ve created a R markdown report where the sections and tabsets are dynamically created.

I have an issue where the Leaflet maps are not being generated in the output

2条回答
  •  青春惊慌失措
    2021-01-16 17:12

    I had a similar issue that was solved by putting the leaflet into a widget frame.

    l <- leaflet() %>% 
      addTiles() %>% 
      addMarkers(map_data$Longitude, map_data$Latitude)
    
    widgetframe::frameWidget(l, width = "100%")
    

    This has the effect of saving html tiles for use in rendering. I'm pretty sure it just wraps the leaflet in a HMTL tag.

提交回复
热议问题