...I Want to download the Map view that contains all my filters and markers and I want to upload it to the server so users can log in and download what they need
I tried the solution to this question This
but it always gives me an error:- Warning: Error in : webshot.js returned failure value: 1
Here is my sample code that similar to my code
header <- dashboardHeader( title = "simple", uiOutput("logoutbtn"))
sidebar <- dashboardSidebar(uiOutput("sidebarpanel"))
body <- dashboardBody(shinyjs::useShinyjs(), uiOutput("body"))
ui<-dashboardPage(header, sidebar, body, skin = "black")
credentials = data.frame(
username_id = c("EEE"),
passod = sapply(c("123"),password_store),
permission = c("basic"),
stringsAsFactors = F
)
server <- function(input, output, session) {
login = FALSE
USER <- reactiveValues(login = login)
observe({
if (USER$login == FALSE) {
if (!is.null(input$login)) {
if (input$login > 0) {
Username <- isolate(input$userName)
Password <- isolate(input$passwd)
if(length(which(credentials$username_id==Username))==1) {
pasmatch <- credentials["passod"][which(credentials$username_id==Username),]
pasverify <- password_verify(pasmatch, Password)
if(pasverify) {
USER$login <- TRUE
} else {
shinyjs::toggle(id = "nomatch", anim = TRUE, time = 1, animType = "fade")
shinyjs::delay(3000, shinyjs::toggle(id = "nomatch", anim = TRUE, time = 1, animType = "fade"))
}
} else {
shinyjs::toggle(id = "nomatch", anim = TRUE, time = 1, animType = "fade")
shinyjs::delay(3000, shinyjs::toggle(id = "nomatch", anim = TRUE, time = 1, animType = "fade"))
}
}
}
}
})
output$logoutbtn <- renderUI({
req(USER$login)
tags$li(a(icon("fa fa-sign-out"), "Logout",
href="javascript:window.location.reload(true)"),
class = "dropdown",
style = "background-color: #eee !important; border: 0;
font-weight: bold; margin:5px; padding: 10px;")
})
output$sidebarpanel <- renderUI({
if (USER$login == TRUE ){
sidebarMenu(
menuItem("something",selectInput("region", label = "Choose Region:",
choices = c("All", "ee", "ww"), multiple = F)),
#Button
downloadButton("downloadData", "Download")
)
}
})
foundational.map <- reactive({
leaflet( width = 1000, height=500) %>%
addTiles("spm")%>%
addPolygons(
weight = 0.5, opacity = 1, color = grey)
output$body <- renderUI({
if (USER$login == TRUE ) {
if(input$userName == "All") {
if(input$region == "ee"){
if(input$project != "All") {
location_input <- location_ee %>% filter(Project == input$project)
foundational.map() %>%
addCircleMarkers(data= location_input,
lat = location_input$Latitude_y,
lng = location_input$Longitude_x,
radius = 2, col = location_input$color) %>%
addLegend(position = "bottomright", colors = c("blue", "orange", "green"),
labels =c("Hsos 791", "jmmi 29", "camps 6"), opacity = 1,
title = "Number of Covarge Area")
} else {
foundational.map() %>%
addCircleMarkers(data= location_ee,
lat = location_ee$Latitude_y,
lng = location_ee$Longitude_x,
radius = 2, col = location_ee$color) %>%
addLegend(position = "bottomright", colors = c("blue", "orange", "green"),
labels =c("Hsos 791", "jmmi 29", "camps 6"), opacity = 1,
title = "Number of Covarge Area")}}
}else {
loginpage
}
})
user.created.map <- reactive({
# call the foundational Leaflet map
foundational.map() %>%
# store the view based on UI
setView( lng = input$map_center$lng
, lat = input$map_center$lat
, zoom = input$map_zoom
)})
output$downloadData <- downloadHandler(
filename = paste0( Sys.Date()
, "Covarge_map"
, ".pdf"
)
, content = function(file) {
mapshot( x = user.created.map()
, file = file
, cliprect = "viewport" # the clipping rectangle matches the height & width from the viewing port
, selfcontained = FALSE # when this was not specified, the function for produced a PDF of two pages: one of the leaflet map, the other a blank page.
)
} # end of content() function
) # end of downloadHandler() function
}
Where Location_ee can be any data. frame that has some gis information like Latitude,
Longitude
I really appreciate any help you can provide.