【发布时间】:2021-12-18 02:42:48
【问题描述】:
我正在开发一个由两个 fluidRows 组成的 R Shiny 应用程序,其中包含一些内容。其中一个包含跨越一些列的传单地图。到目前为止,一切都很好。现在,想法是将背景中的地图扩展到其他列以及上方的fluidRow。最后,整个网站都可以看到地图:columns 不透明,另一个columns 和上面的fluidRow 半透明。
这是应用程序的代码:
library(leaflet)
library(shiny)
library(shinythemes)
ui <- navbarPage(
title = "The app",
tabPanel("Reproducible examples are great :)",
fluidPage(
fluidRow(
column(2,
selectInput("city", "Select city:",
c("Beirut", "Cairo", "Bagdad"),
selected = "Beirut"
),
actionButton("start", "Start",
style = "color: black;
background-color: #ffcc00;")
),
column(5,
"Content is here ...",
br(),
sliderInput("slider1", "",
min = 1,
max = 100,
value = 30,
ticks = TRUE)
),
column(5,
"... and there and ...",
br(),
sliderInput("slider2", "",
min = 1,
max = 100,
value = 30,
ticks = TRUE)
),
),
fluidRow(
column(7,
leafletOutput("map",
height = "67vh"
)
),
column(5,
"... also here ...",
br(),
sliderInput("slider3", "",
min = 1,
max = 500,
value = 30,
ticks = TRUE),
"... and even down there",
br(),
sliderInput("slider4", "",
min = 1,
max = 500,
value = 30,
ticks = TRUE)
)
)
)
),
theme = shinytheme("cosmo")
)
server <- function(input, output) {
output$map <- renderLeaflet({
leaflet(data = NULL,
options = leafletOptions(zoomControl = FALSE,
dragging = TRUE)) |>
addTiles(
options = providerTileOptions(noWrap = TRUE)) |>
setView(lng = 35.5051, lat = 33.889, zoom = 14) |>
addScaleBar(position = "bottomleft")
})
}
shinyApp(ui, server)
我试图在网上寻找解决方案,但失败了,甚至没有找到真正的灵感:(所以,如果你们中的任何人知道解决方案或提示,我就更加好奇了!提前谢谢你:)
【问题讨论】: