【发布时间】:2021-02-16 12:36:20
【问题描述】:
我可以在 R shiny 应用程序中更改关于 r-leaflet 的光标,但似乎无法弄清楚如何仅针对特定地图执行此操作。似乎最后一个tags$style 应用于所有以前的地图?我添加了一个只有两张地图的代表,但同样的逻辑可以应用于更多。任何帮助将不胜感激,因为它让我大吃一惊!谢谢。
library(shinydashboard)
library(leaflet)
library(tidyverse)
header = dashboardHeader(title = "Hydroclimatic Data")
# * sidebar ----
sidebar = dashboardSidebar(
sidebarMenu(
menuItem(
"Map",
tabName = "map",
menuSubItem("Map", tabName = "map", icon = icon("chart-line"))
),
menuItem(
"Map2",
tabName = "map2",
menuSubItem("Map2", tabName = "map2", icon = icon("chart-line"))
)))
body = dashboardBody(
tabItems(
tabItem(
tabName = "map",
tags$style(type = 'text/css', '
.leaflet-container {
cursor: crosshair !important;}'),
fluidRow(
tabBox(width = 12, id = "tab",
tabPanel("Map", style = "height:92vh;",leafletOutput("swe_maps"))))
),
# * * -- Snotel - Raw ----
tabItem(
tabName = "map2",
tags$style(type = 'text/css', '
.leaflet-container {
cursor: help !important;}'),
fluidRow(
tabBox(width = 12, id = "tabchart",
tabPanel("Map", style = "height:92vh;",leafletOutput("swe_maps2")))))))
# UI ----------------------------------------------------------------------
ui <- dashboardPage(header = header, sidebar = sidebar, body = body)
# Server ------------------------------------------------------------------
server <- function(input, output, session) {
output$swe_maps <- renderLeaflet({leaflet("map1") %>% addTiles()})
output$swe_maps2 <- renderLeaflet({leaflet("map2") %>% addTiles()})
}
##### RUN APPLICATION #####
shinyApp(ui = ui, server = server)
【问题讨论】:
标签: shiny r-leaflet r shiny leaflet shinydashboard r-leaflet