【问题标题】:mapview and shiny: how to change the color palette interactivelymapview 和闪亮:如何以交互方式更改调色板
【发布时间】:2018-12-10 03:24:16
【问题描述】:

我想使用 mapview 包 - 它非常快 - 闪亮。 为了渲染 mapview 对象,@map 技巧就像一个魅力。

但是,与ggplot2 相比,使mapview_leaflet 对象具有反应性是相当复杂的。在我闪亮的应用程序中,我想让调色板交互。这可能吗?

library(mapview)
library(shiny)

server <- function(input, output) {
  output$test <- renderLeaflet({
    req(input$obs)
    rws <- input$obs
    mapview(breweries91[1:rws,])@map
  })
}

ui <- fluidPage(
  sidebarLayout(
    sidebarPanel(
      sliderInput("obs", "Number of observations:", min = 1, max = nrow(breweries91@data), value = nrow(breweries91@data))
    ),
    mainPanel(
      leafletOutput('test')
    )
  )
)

shinyApp(ui = ui, server = server)

【问题讨论】:

  • 欢迎来到 Stack Overflow!如果您展示了一个最小的、完整的、可验证的可重现示例应用程序,然后描述或展示您需要如何修改它以执行您想要的操作,这将是一个非常更好的问题。
  • 代码取自github.com/r-spatial/mapview/issues/58 它使使用的数据集具有反应性。
  • 我认为这有帮助。您可能希望添加该行以加载该代码中使用的数据(我认为它是内置在某些包中)并描述您想要的输出与这会产生更多的内容。
  • mapview 函数有参数 col.regions。也许将这个额外的参数与radioButton结合起来就足够了
  • 我会试一试

标签: r shiny leaflet reactive


【解决方案1】:

我可以确认,通过使输入数据和 mapview 对象反应,mapview 和闪亮的工作就像 @map hack 的魅力。与leaflet-easyprint plugin 结合使用,它是创建和导出地图的非常有用的工具。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-06-28
    • 1970-01-01
    • 2020-01-14
    • 1970-01-01
    • 2019-05-20
    • 2015-10-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多