首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Leafletoutput在dashboardBody中不显示

Leafletoutput在dashboardBody中不显示
EN

Stack Overflow用户
提问于 2019-05-17 20:43:35
回答 1查看 71关注 0票数 0

嗨,我正在使用shinydashboard为一些光栅文件建立一些可视化。我正在使用leafletOutput来显示地图。

在第一个名为“KmeansOutput”的tabItem下,我想显示小叶地图。当我不包含selectInput时,它会显示地图,但一旦我包含selectInput,它就不会显示地图。我不确定哪一部分出了问题。提前感谢!!

以下是代码的UI部分:

代码语言:javascript
复制
library(shinydashboard)
library(leaflet)


sidebar <- dashboardSidebar(
    sidebarMenu(
        menuItem("KmeansOutput", tabName = "kmeans", icon = icon("kmeans"),
                 selectInput("run1",
                             "SoilAllWeatherAll",
                             choices = c('4' = 1, '5' = 2),
                             multiple = TRUE)
),
        menuItem("HistoricalWeather", icon = icon("weather"), tabName = "weather"),
        menuItem("SoilMap", icon = icon("soil"), tabName = "soil")
    )
)

body <- dashboardBody(
    tabItems(
        tabItem(tabName = "kmeans",
                leafletOutput("map", height = 700)
        ),

        tabItem(tabName = "weather",
                h2("weather")),
        tabItem(tabName = "soil",
                h2('soil'))
    )
)

    # Put them together into a dashboardPage
ui <- dashboardPage(
        dashboardHeader(title = "Genome Prediction"),
        sidebar,
        body)

下面是服务器:

代码语言:javascript
复制
server <- function(input, output) {

    output$map <- renderLeaflet({
        leaflet() %>%
            addTiles() 
    })
}

shinyApp(ui, server)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-05-17 21:02:38

您需要向k-means siderbar项添加一个子项,如下所示。

代码语言:javascript
复制
sidebar <- dashboardSidebar(
  sidebarMenu(
    menuItem("KmeansOutput", #icon = icon("kmeans"),
             menuSubItem(
               "K-Means Map", tabName = "kmeans", icon = icon("calendar")
             ),
             selectInput("run1",
                         "SoilAllWeatherAll",
                         choices = c('4' = 1, '5' = 2),
                         multiple = TRUE)
    ),
    menuItem("HistoricalWeather", tabName = "weather"), #icon = icon("weather"),
    menuItem("SoilMap", tabName = "soil")#, icon = icon("soil")
  )
)
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56186672

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档