【问题标题】:Leaflet map not rendering in shiny app but rendering in console传单地图不在闪亮的应用程序中呈现,但在控制台中呈现
【发布时间】:2020-02-22 09:27:15
【问题描述】:

我正在创建一个 Shiny App 仪表板,该仪表板涉及在其中一个选项卡中使用 Leaflet 使用纬度和经度绘制地图。我需要用于缩放的传单和弹出选项。但是,地图不会在应用程序中呈现,它不会引发任何错误,并且会在理想情况下显示地图的灰色空间。 R 控制台没有这样的问题,它完美地渲染了地图。

我在下面的链接中发现了一个类似的问题,但它并没有解决我的问题。 Shiny/Leaflet map not rendering.

我也尝试了下面这个链接中提到的解决方法,但它破坏了我的其他情节。 https://github.com/rstudio/shiny/issues/650

ui <- dashboardPage(
  dashboardHeader(title = "Crimes Dashboard"),

  dashboardSidebar(
    sidebarMenu(
      menuItem("Tab1", tabName = "Tab1" , icon=icon("th")),
      menuItem("Tab2", tabName = "Tab2" , icon=icon("th")),
      menuItem("Tab3", tabName = "Tab3" , icon=icon("th")),
      menuItem("Tab4", tabName = "Tab4" , icon=icon("th"))
    )
  ),

  dashboardBody(
    tabItems(

      #Fourth Tab
      tabItem(tabName = "Tab4",
              h2("Tab4"),
              leafletOutput(outputId = "mymap")


      )

    )
  )
)


server <- function(input, output, session) {

  reactive_data2 <- reactive({
  crime <- crime[-which (is.na(crime$Location)),]
  })

  output$mymap <- renderLeaflet({

    reactive_data2() %>%
    mutate(popup = str_c(Date,
                         Block,
                         str_c("Location type:", `Location Description`,
                               sep = " "),
                         sep = "<br/>")) %>%
    leaflet() %>%
    addTiles() %>%
    addMarkers(clusterOptions = markerClusterOptions(),popup = ~popup) %>%
    frameWidget() 

  })
}

shinyApp(ui, server)

【问题讨论】:

标签: r dictionary shiny leaflet


【解决方案1】:

我找到了解决方案,从最后删除 frameWidget() 解决了这个问题,谢谢!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-01-13
    • 2015-09-04
    • 2018-09-24
    • 2017-10-30
    • 1970-01-01
    • 2020-08-28
    • 2018-10-06
    相关资源
    最近更新 更多