【问题标题】:How to change background of Leaflet map in RStudio?如何在 RStudio 中更改 Leaflet 地图的背景?
【发布时间】:2017-04-17 00:37:42
【问题描述】:

我正在使用传单小部件创建一个闪亮的应用程序。我的地图有一个简单的 Shapefile,没有使用底图。 Leaflet 呈现默认的灰色背景。我想将背景更改为白色。

我看到一些使用 javascript 代码的答案,但我不熟悉如何在 R 语言中实现它。

【问题讨论】:

    标签: r shiny leaflet


    【解决方案1】:

    您可以使用 CSS 更改 Leaflet 默认背景颜色,请参阅this related question

    您可以通过将自定义 CSS 添加到 Shiny 输出的 HTML 头中来在 Shiny 应用中使用自定义 CSS:

    ui <- fluidPage(
      tags$head(
        tags$style(HTML(".leaflet-container { background: #f00; }"))
      ),
      # etc.
    )
    # etc.
    

    Shiny documentation 中解释了添加样式的其他可能性,例如使用外部 CSS 文件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-03-22
      • 1970-01-01
      • 2022-10-13
      • 2022-07-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多