'R Leaflet does not show legend when embedded in Shiny Dashboard

Leaflet as standalone map

The map above renders perfectly fine in the following scenarios:

  • List item
  • RStudio Viewer
  • Shiny app
  • Shiny app using a minimal Shiny dashboard sceleton

When including the map in an existing, pretty complex Shiny dashboard, the looks as follows:

enter image description here

Obviously, the legend is missing. On top of that, the "reset view" action button has no effect.

Without posting the complete code of the complex shiny dashbboard, I would like make the following comments:

  • I have disabled all custom JS code and CSS
  • I use a bare "renderLeaflet" function without additional arguments
  • I have also tried to display the leaflet in a bare dashboard box without any further arguments

Any obvious culprit anyone could think of causing this issue? Anyone observed similar issues?



Solution 1:[1]

I wonder if you solved the issue. I noticed the legend of a raster layer disappears when using the function d3heatmap, for instance d3heatmap(mtcars, scale="column", colors="Blues"). When the line with the heatmap is commented out the dashboard knites just fine -even when the library d3heatmap is loaded. I used the code from this example. Oh I just noticed this has been addressed and solved in other questions, for example here.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1