我想知道,如何在闪亮的R中更改传单地图的大小。例如,考虑以下代码:
library(leaflet)
library(shiny)
app = shinyApp(
ui = fluidPage(
sidebarLayout(
sidebarPanel( sliderInput("obs",
"Number of observations:",
min = 0,
max = 1000,
value = 500)
),
mainPanel(
leafletOutput('myMap', width = "200%", height = 1400)
)
)
),
server = function(input, output) {
map = leaflet() %>% addTiles() %>% setView(-93.65, 42.0285, zoom = 17)
output$myMap = renderLeaflet(map)
}
)
if (interactive()) print(app)
为了更改地图的大小,我可以在ui中更改width和height参数。当我尝试更改服务器中的相同名称时,它没有解决。
我不知道,可以通过服务器更改ui中的参数的任何方式。我尝试了这种方法,但是没有用。
library(leaflet)
library(shiny)
Height = 1000
app = shinyApp(
ui = fluidPage(
sidebarLayout(
sidebarPanel( sliderInput("Height",
"Height in Pixels:",
min = 100,
max = 2000,
value = 500)
),
mainPanel(
leafletOutput('myMap', width = "200%", height = Height)
)
)
),
server = function(input, output) {
Height <- reactive(input$Height)
map = leaflet() %>% addTiles() %>% setView(-93.65, 42.0285, zoom = 17)
output$myMap = renderLeaflet(map)
}
)
if (interactive()) print(app)
我只想知道如何使地图的大小动态化,以便我可以控制它。任何帮助是极大的赞赏。
您需要leafletOutput
在服务器端进行渲染,例如
app = shinyApp(
ui = fluidPage(
sidebarLayout(
sidebarPanel( sliderInput("Height",
"Height in Pixels:",
min = 100,
max = 2000,
value = 500)
),
mainPanel(
uiOutput("leaf")
)
)
),
server = function(input, output) {
output$leaf=renderUI({
leafletOutput('myMap', width = "200%", height = input$Height)
})
output$myMap = renderLeaflet(leaflet() %>% addTiles() %>% setView(-93.65, 42.0285, zoom = 17))
}
)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句