diff --git a/app/logic/disease_outbreaks/disease_leaflet_map.R b/app/logic/disease_outbreaks/disease_leaflet_map.R index bebbf2e..6948658 100644 --- a/app/logic/disease_outbreaks/disease_leaflet_map.R +++ b/app/logic/disease_outbreaks/disease_leaflet_map.R @@ -21,7 +21,7 @@ disease_outbreak_leaflet_map <- function(id, tif_map, tif_map_path, tif_map_repr # load tif raster, hardcoded for prototype (terra) tif_map_path() |> - read_disease_outbreak_raster |> + read_disease_outbreak_raster() |> tif_map() # project to right CRS (terra) diff --git a/app/view/disease_outbreaks/disease_app/disease_app.R b/app/view/disease_outbreaks/disease_app/disease_app.R index 20d6cc3..d97e970 100644 --- a/app/view/disease_outbreaks/disease_app/disease_app.R +++ b/app/view/disease_outbreaks/disease_app/disease_app.R @@ -36,14 +36,14 @@ disease_app_server <- function(id, r) { ns <- session$ns # Variables ---- - tif_map <- reactiveVal() - tif_map_path <- reactiveVal() + tif_map <- reactiveVal(NULL) + tif_map_path <- reactiveVal(NULL) # selection of raster map - tif_map <- disease_select_server("disease_select") - print(tif_map) + disease_select_server("disease_select") + # print(tif_map_name) # MAP itself ---- - disease_map_server("disease_map", tif_map()) + disease_map_server("disease_map", map_selected = tif_map()) }) } diff --git a/app/view/disease_outbreaks/disease_app/disease_map.R b/app/view/disease_outbreaks/disease_app/disease_map.R index db50e7f..2b26080 100644 --- a/app/view/disease_outbreaks/disease_app/disease_map.R +++ b/app/view/disease_outbreaks/disease_app/disease_map.R @@ -1,11 +1,11 @@ box::use( - shiny[NS, moduleServer, tags, observeEvent], + shiny[NS, moduleServer, tags, observeEvent, reactive], bslib[card, card_header, card_body], leaflet[setView, leaflet, leafletOptions, leafletOutput, renderLeaflet, addTiles], ) box::use( - app/logic/honeybee/honeybee_beekeeper_map[read_honeybee_tif, honeybee_leaflet_map] + app/logic/disease_outbreaks/disease_leaflet_map[read_disease_outbreak_raster, make_full_tif_map_path, disease_outbreak_leaflet_map] ) #' @export @@ -34,8 +34,11 @@ disease_map_server <- function(id, map, map_selected) { moduleServer(id, function(input, output, session) { ns <- session$ns - observeEvent(map_selected(), { - + map <- reactive(map_selected) + + + observeEvent(map(), { + print(map()) }) }) diff --git a/app/view/disease_outbreaks/disease_app/disease_select.R b/app/view/disease_outbreaks/disease_app/disease_select.R index 54d5198..c57394f 100644 --- a/app/view/disease_outbreaks/disease_app/disease_select.R +++ b/app/view/disease_outbreaks/disease_app/disease_select.R @@ -20,7 +20,7 @@ disease_select_ui <- function(id, theme, i18n) { ), card_body( selectInput( - "disease_map_select", + ns("disease_map_select"), label = "Select disease map:", choices = c("Mosaic_final", "outfirst_infection"), multiple = FALSE @@ -31,18 +31,21 @@ disease_select_ui <- function(id, theme, i18n) { } #' @export -disease_select_server <- function(id) { +disease_select_server <- function(id, map) { moduleServer(id, function(input, output, session) { ns <- session$ns - out <- reactiveVal() - - observeEvent(input$disease_map_select, { + observeEvent( + input$disease_map_select, + ignoreInit = TRUE, + ignoreNULL = TRUE, + { print(input$disease_map_select) - out <- input$disease_map_select }) - reactive(out()) + reactive({ + input$disease_map_select + }) }) } \ No newline at end of file