0

Putting together a map on Shiny, but keep running into an error. When I use the same steps using Leaflet, it runs fine, but when I use mapview, it does not. Unfortunately, I can't provide the data for a reproducible example, seeing as it involves a shaping file with length geometry.

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)

Whenever I run it, I get stuck with the following error:

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]

0 Answers0