Closed fliermanrw closed 5 years ago
Does the shiny example work for you?
I just tested it and there everything works as expected, in this case you can also call getDockerContainerName()
in the developer console. This function is only used when using drag-and-drop and layer switcher to give random layer names.
From the code snippet I cannot see what goes wrong. Maybe you can send the complete example.
Thank you for the reply. I have tried to find the problem and it seems to occur when I try to render with renderUI (to a uiOutput). Please see the following:
library(shiny)
library(geojsonio)
library(openlayers)
view <- fluidPage(
h1("openlayers"),
olOutput("ol_map", height = "800px")
)
server <- function(input, output) {
output$ol_map <- renderOl({
ol(options = ol_options(debug = TRUE)) %>%
add_stamen_tiles() %>%
add_features(us_cities[1:10, ], style = circle_style()) %>%
add_select() %>%
add_drag_and_drop()
# out <- div(id = "jo", column(width = 12, olOutput("ol_map", height = "800px")))
# output$onderzoekui <- renderUI(
#
# olOutput("ol_map", height = "800px")
# )
})
}
shinyApp(view, server)
The code above shows correctly. This code however:
library(shiny)
library(geojsonio)
library(openlayers)
view <- fluidPage(
h1("openlayers"),
uiOutput("onderzoekui")
#olOutput("ol_map", height = "800px")
)
server <- function(input, output) {
output$ol_map <- renderOl({
ol(options = ol_options(debug = TRUE)) %>%
add_stamen_tiles() %>%
add_features(us_cities[1:10, ], style = circle_style()) %>%
add_select() %>%
add_drag_and_drop()
# out <- div(id = "jo", column(width = 12, olOutput("ol_map", height = "800px")))
output$onderzoekui <- renderUI(
#also tried out
olOutput("ol_map", height = "800px")
)
})
}
shinyApp(view, server)
So the problem seems to be that the olOutput cannot be rendered into a uiOutput.
You are right, there was some strange behavior when rendering the widget via renderUI
, so that the function getDockerContainerName
was not available in the global namespace. I fixed the bug and merged it to master. Please install the latest version of openlayers for R (see releases) and try to run the example shiny-render-ui.R. It should work now.
Awesome, thank you for fixing this bug!
Hi,
The openlayer map does render in RStudio Viewer but does not render to Shiny dashboard. When rendering Ol to shiny dashboard, I get the following message:
My code:
The "openlayers$create_map()" returns the Ol map (that works in viewer).
What is wrong?