I have a shiny application that runs just fine in Rstudio, but when I "press the button" when it is running on the shinyapps.io server, it crashes. What is particularly frustrating is that the log file is empty. It doesn't even display the output of print statements that must have happened (is there some sort of buffering for the log? Maybe I need to print a bunch of junk to force a buffer flush?). Possibly running out of memory? But how would I know that? Anyway, here is my reprex:
#
# Reprex for addGeotiff reading from a url
#
# Alan Jackson, 4 Jan 2025
#
library(shiny)
library(tidyverse)
library(leaflet)
library(sf)
Local_test <- FALSE # running locally or on web
DataLocation <- "https://www.ajackson.org/ERD/Sealevel/"
Tiff_path <- "/media/ajackson/extradrive1/SeaLevel/Newer/"
infile <- "AL_slr_depth_10ft.tif_small.tif"
Draw_water <- function(){
print("*******draw water****************")
if (Local_test) {
print("--1--")
foo <- leafletProxy("map") %>%
leafem::addGeotiff(
file=paste0(Tiff_path, infile),
group="Water",
opacity=0.8,
autozoom = FALSE,
colorOptions = leafem::colorOptions(
palette = "Blues",
na.color = "transparent"
)
)
} else {
foo <- leafletProxy("map") %>%
leafem::addGeotiff(
url=paste0(DataLocation, infile),
group="Water",
opacity=0.8,
autozoom = FALSE,
colorOptions = leafem::colorOptions(
palette = "Blues",
na.color = "transparent"
)
)
}
foo
}
############################################################
# Define UI
############################################################
ui <- fluidPage(
# Application title
titlePanel("Reprex for addGeotiff"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
actionButton("Draw", "Draw Water")
),
# Show a plot of the generated distribution
mainPanel(
leafletOutput("map")
)
)
)
############################################################
# Define server logic
############################################################
server <- function(input, output) {
output$map <- leaflet::renderLeaflet({
print("--5--")
leaflet() %>% addTiles() %>%
setView(lng=-87.8834544324183,
lat=30.7726345266383,
zoom=8)
})
observeEvent(input$Draw, {
Draw_water()
})
}
# Run the application
shinyApp(ui = ui, server = server)