Skip to content

Commit

Permalink
map files was inside plot.zip so not available to report.html inside …
Browse files Browse the repository at this point in the history
…saved zip.
  • Loading branch information
xhdong-umd committed Sep 17, 2018
1 parent 8c28eac commit d9a1d12
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 8 additions & 1 deletion inst/app/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -2820,13 +2820,18 @@ output:
# save map to html, record html path in CURRENT_map_path. this is used in log save, and download map button.
save_map <- function(leaf, map_type) {
map_file_name <- stringr::str_c(map_type, "_", ctmmweb:::current_timestamp(), ".html")
map_file_adjacent_folder_name <- stringr::str_c(map_type, "_", ctmmweb:::current_timestamp(), "_files")
# LOG saving map
log_msg(stringr::str_c("Saving map: ", map_type))
map_path <- file.path(LOG_folder, map_file_name)
# the library folder is still saved even with selfcontained = TRUE. This didn't happen in vignettes script. the source code said pandoc is needed for selfcontained option, but there is no error message.
# the library folder is still saved even with selfcontained = TRUE. This didn't happen in vignettes script. [pandoc is needed for selfcontained option, but there is no error message](https://github.com/ramnathv/htmlwidgets/blob/master/R/savewidget.R#L46)
htmlwidgets::saveWidget(leaf, file = map_path, selfcontained = TRUE)
# remove the library folder as it is not needed, also too many files
unlink(file.path(LOG_folder, map_file_adjacent_folder_name), recursive = TRUE)
# add link in rmd, difficult to embed map itself.
log_add_rmd(stringr::str_c("\n[", map_type, "](", map_file_name, ")\n"))
# link can be opened in previewed report, also need to put in same folder of report html generated in `download progress` to make it available
file.copy(map_path, file.path(session_tmpdir, map_file_name))
# record the latest file path
CURRENT_map_path[[map_type]] <<- map_path
}
Expand Down Expand Up @@ -3032,6 +3037,8 @@ output:
saved_zip_path <- ctmmweb:::zip_relative_files(
session_tmpdir, files_to_save,
file.path(saved_zip_folder, "saved.zip"))
# after zip generated, remove generated files in session temp folder. Because we copied map files here, if we don't clean up, 2nd saved progress will have map files in first save zipped too. NO, same session should have these files kept, new save will update same name file, and map files need to be kept since they are all needed in same session report
# unlink(file.path(session_tmpdir, files_to_save))
file.copy(saved_zip_path, file, overwrite = TRUE)
}
}
Expand Down
2 changes: 0 additions & 2 deletions vignettes/package_usage.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,6 @@ plot_ud(occur_list_sub2, level_vec = c(0.50, 0.95))
We can then build interactive online maps of the data and fitted Home Range and Occurrence distributions. For example, one can display the location data on a map via:

```{r point map, eval=TRUE}
# this is needed for using pipe operator
library(leaflet)
# loc_data_sub1 is used for visualization plot. all the model selections above are based on a different subset. We need to get corresponding loc_data subset for model selections
loc_data_sub2 <- loc_data[identity %in% names(tele_list_sub2)]
point_map(loc_data_sub2)
Expand Down

0 comments on commit d9a1d12

Please sign in to comment.