首页 > 解决方案 > 闪亮的传单

问题描述

数据框是一个

样本数据如下

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)

闪亮代码的一些问题

标签: rshiny

解决方案


问题似乎出height = "100%"leafletOutput您的tabPanel. 我确实在这里找到了相关的解决方案。这是基于SuperZip ui。

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)
                               )
                             )
                    )
        )
      )
    )
  )

推荐阅读