数据框是
样本数据如下
ID Lat Long Address
1 12.904249 77.70253 1/2 CA
2 21.221475 72.81281 2/3 DC
3 23.039251 72.58388 3/5 HJ
library (leaflet)
shinyApp(
ui = fluidPage(
titlePanel("Lat Long Address Mapping in R"),
fluidRow(
mainPanel(
tabsetPanel(type = "tabs",
tabPanel("Map",
bootstrapPage(
tags$style(type = "text/css", "html, body {width:100%;height:100%}"),
leafletOutput("map", width = "100%", height = "100%"),
absolutePanel(
top = 80,
left = 30,
)
)
)
,
server = function(input, output,session) {
output$map <- renderLeaflet({
leaflet(a) %>%
addProviderTiles("CartoDB.Positron") %>%
addMarkers(lng = ~Long, lat = ~Lat,
popup = ~address)})
输出显示闪亮的黑屏
但是当我独立运行此代码时,它可以工作并绘制地图
leaflet(a) %>%
addProviderTiles("CartoDB.Positron") %>%
addMarkers(lng = ~Long, lat = ~Lat,
popup = ~Address)
一些闪亮的代码问题
答案 0 :(得分:0)
问题似乎出在height = "100%"
中的leafletOutput
中有tabPanel
。我确实找到了相关的解决方案here。这基于SuperZip用户界面。
ui = fluidPage(
titlePanel("Lat Long Address Mapping in R"),
fluidRow(
mainPanel(
tabsetPanel(type = "tabs",
tabPanel("Map",
bootstrapPage(
div(class = "outer",
tags$style(type = "text/css", ".outer {position: fixed; top: 120px; left: 0; right: 0; bottom: 0; overflow: hidden; padding: 0}"),
leafletOutput("map", width = "100%", height = "100%"),
absolutePanel(top = 80, left = 30)
)
)
)
)
)
)
)