将地图放在Shiny上,但会遇到错误。当我使用Leaflet使用相同的步骤时,它可以正常运行,但是当我使用mapview时,它不能运行。不幸的是,我无法提供可重现示例的数据,因为它涉及具有长度几何形状的整形文件。
library(sf)
library(shiny)
library(shinyWidgets)
library(dplyr)
library(leaflet)
library(mapdeck)
ui <- fluidPage(
fluidRow(
column(
width = 10, offset = 1,
tags$h3("Select Area"),
panel(
selectizeGroupUI(
id = "my-filters",
params = list(
state = list(inputId = "state", title = "state:"),
city = list(inputId = "city", title = "city:"),
turf = list(inputId = "turf", title = "turf:")
))
),
mapviewOutput(outputId = "mymap")
)
)
)
server <- function(input, output, session) {
res_mod <- callModule(
module = selectizeGroupServer,
id = "my-filters",
data = df,
vars = c("state", "city", "turf")
)
output$box <- mapview::renderMapview({
res <- res_mod()
mapView(res)
})
}
shinyApp(ui, server)
每次运行它时,都会遇到以下错误:
Warning: Error in .getReactiveEnvironment()$currentContext: Operation not allowed without an active reactive context. (You tried to do something that can only be done from inside a reactive expression or observer.)
63: stop
62: .getReactiveEnvironment()$currentContext
61: getCurrentContext
60: .dependents$register
59: cheat
52: server [#23]