-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
repeat_view = TRUE
does not work within Shiny
#349
Comments
Thanks for the report; yes I can reproduce this also. But it's strange it only happens in shiny, and not a standard plot. |
It is strange, indeed. I can't tell you why, unfortunately. FYI, it works when using library(data.table)
library(sf)
library(rdeck)
library(shiny)
options(rdeck.mapbox_access_token = "***")
n <- 1000L; x0 <- -179; y0 <- -42
pts <- data.table(x = rnorm(n, x0, 2), y = rnorm(n, y0, 2), indiv = sample(LETTERS, n, repl=T))
pts <- st_as_sf(pts, coords = c('x', 'y'), crs = 4326, remove = F)
shinyApp(
ui = fluidPage(rdeckOutput('map', height='800px')),
server = function(input, output) {
output$map <- renderRdeck({
rdeck(initial_view_state = view_state(center = c(x0, y0) , zoom = 3),
map_style = 'mapbox://styles/mapbox/dark-v10'
) %>%
add_scatterplot_layer(data = pts ,
get_fill_color = scale_color_category(
col = indiv,
palette = colorRampPalette(colors = get_palette('rainbow_hcl', F))(length(unique(pts$indiv)))
) , opacity = 0.5,
radius_min_pixels = 2)
})
}
) |
I've narrowed it down and the error is coming from the drag events (which are only available in a Shiny app, hence only getting the error there). I'll keep looking for a solution |
I really have no idea what changed in either {shiny} or deck.gl to cause the circular reference, but I've followed the solution here and it seems to work. You can test it now if you want using |
That sounds great, thank you! Unfortunately I get this error when trying to install the new version:
|
try now. |
Brilliant, working now! Thank you so much! |
Notes / Tests:
No, don't stringify; use a function in stead, something like function removeCircular(obj) {
const seen = new WeakSet();
const recurse = obj => {
seen.add(obj,true);
for( let [k, v] of Object.entries(obj)) {
if( typeof v === "object" && v !== null) {
if(seen.has(v)) delete obj[k];
else recurse(v);
} else {
continue;
}
}
}
recurse(obj);
} |
Describe the bug
repeat_view = TRUE
leads to a frozen view within Shiny with the browser console returning plenty ofUncaught TypeError: cyclic object value
To Reproduce
Expected behaviour
Features on both sides of the international date line should get displayed with
repeat_view=TRUE
. This option is essential when dealing with features around the date line, as otherwise half of them disappear when dragging the view left or right.Versions
The text was updated successfully, but these errors were encountered: