【发布时间】: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)
【问题讨论】:
-
嗨,您能否提供您正在使用的
crime数据库的示例? -
这是一个大文件(至少 700Mb),您能否在代码中添加该数据库的示例(例如
head)?
标签: r dictionary shiny leaflet