Legend doesnt show up when using add_grid in RMarkdown file
samatt opened this issue · comments
Describe the bug
When I run the following code in an RScript it works just find and produces a map with a legend in the bottom left corner as I would expect. When I run the exact same code in an RMarkdown file the legend no longer appears. When I inspect the generated html the legendContainerhtmlwidget
is empty, suggesting that there is some problem with how the html is generated, rather than something to do with styling.
To Reproduce
Here is the code i run.
mapdeck(token = MAPBOX_ACCESS_TOKEN, style = mapdeck_style("satellite-streets")) %>%
add_grid(
data = data,
lat = "lat",
lon = "lon",
colour_function = "sum",
colour = "count",
cell_size = 150,
colour_range = colourvalues::colour_values(1:6, palette = "purd", alpha = 0.5),
layer_id = "grid_layer",
extruded = FALSE,
legend = TRUE,
focus_layer = TRUE,
legend_options = list(title = "My Label")
)
The data is really simple, just the following columns lat,lon,count.
Thanks in advance!
Thanks for the suggestion I just ran the same code and dont get a legend
df <- read.csv(paste0(
'https://raw.githubusercontent.com/uber-common/deck.gl-data/master/',
'examples/3d-heatmap/heatmap-data.csv'
))
df <- df[ !is.na(df$lng ), ]
mapdeck( token = MAPBOX_API_KEY, style = mapdeck_style("dark"), pitch = 45 ) %>%
add_grid(
data = df
, lat = "lat"
, lon = "lng"
, cell_size = 5000
, elevation_scale = 50
, layer_id = "grid_layer"
, auto_highlight = TRUE,
legend = T,
legend_options = list(tite = "Test Legend")
)
A few questions:
- Is that within a markdown document?
- Which browser are you using
- a. Are there any javascript errors in the console? (in Chrome press Ctrl+Shift+C, then select the 'console' tab)
- Which version of mapdeck