r-tmap / tmap

R package for thematic maps
https://r-tmap.github.io/tmap
GNU General Public License v3.0
865 stars 121 forks source link

Shiny renderTmap not rendering #739

Closed see24 closed 1 year ago

see24 commented 1 year ago

I have a shiny app that uses tmap and the maps have stopped showing up after some recent updates.

Even the example from the renderTmap docs does not work.

library(tmap)
library(shiny)
data(World)
world_vars <- setdiff(names(World), c("iso_a3", "name", "sovereignt", "geometry"))

ui <- fluidPage(
  tmapOutput("map"),
  selectInput("var", "Variable", world_vars)
)

server <- function(input, output, session) {
  output$map <- renderTmap({
    tm_shape(World) +
      tm_polygons(world_vars[1], zindex = 401)
  })
}   

app <- shinyApp(ui, server)
if (interactive()) app

Session info:

R version 4.3.1 (2023-06-16 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

Matrix products: default

locale:
[1] LC_COLLATE=English_Canada.utf8  LC_CTYPE=English_Canada.utf8    LC_MONETARY=English_Canada.utf8
[4] LC_NUMERIC=C                    LC_TIME=English_Canada.utf8    

time zone: America/Toronto
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] shiny_1.7.4.1 tmap_3.3-3   

loaded via a namespace (and not attached):
 [1] sass_0.4.6         utf8_1.2.3         generics_0.1.3     class_7.3-22       lwgeom_0.2-13     
 [6] KernSmooth_2.23-21 lattice_0.21-8     digest_0.6.32      magrittr_2.0.3     grid_4.3.1        
[11] RColorBrewer_1.1-3 fastmap_1.1.1      jsonlite_1.8.5     e1071_1.7-13       leafsync_0.1.0    
[16] DBI_1.1.3          promises_1.2.0.1   fansi_1.0.4        crosstalk_1.2.0    viridisLite_0.4.2 
[21] XML_3.99-0.14      jquerylib_0.1.4    codetools_0.2-19   abind_1.4-5        cli_3.6.1         
[26] crayon_1.5.2       rlang_1.1.1        units_0.8-2        tmaptools_3.1-1    ellipsis_0.3.2    
[31] cachem_1.0.8       base64enc_0.1-3    tools_4.3.1        raster_3.6-20      parallel_4.3.1    
[36] memoise_2.0.1      dplyr_1.1.2        httpuv_1.6.11      mime_0.12          vctrs_0.6.3       
[41] R6_2.5.1           png_0.1-8          proxy_0.4-27       lifecycle_1.0.3    classInt_0.4-9    
[46] leaflet_2.1.2.9000 htmlwidgets_1.6.2  pkgconfig_2.0.3    bslib_0.5.0        later_1.3.1       
[51] terra_1.7-39       pillar_1.9.0       glue_1.6.2         Rcpp_1.0.11        sf_1.0-13         
[56] tibble_3.2.1       tidyselect_1.2.0   rstudioapi_0.14    dichromat_2.0-0.1  xtable_1.8-4      
[61] htmltools_0.5.5    leafem_0.2.0       compiler_4.3.1     sp_2.0-0           stars_0.6-1     
BFroebRPG commented 1 year ago

Did you ever get this problem resolved? I seem to be having a similar issue?

see24 commented 1 year ago

No, I ended up going with Leaflet directly since I was making quite a few customizations that tmap was starting to struggle with. You could check out the changes that I made recently in this file if you are attempting a similar transition. https://github.com/LandSciTech/ccviR/blob/master/R/app_utils_server.R Watch out for CRS differences as tmap was fixing those under the hood

mtennekes commented 1 year ago

Same as #767 Should be fixed now.