我可以更改R shiny应用程序中有关r-leaflet的光标,但似乎不知道如何仅针对特定地图执行此操作。似乎最后一个tags$style应用于所有以前的地图?我已经添加了一个只有两个map的reprex,但是相同的逻辑可以应用于更多的map。任何帮助都是非常感谢的,因为它让我抓狂!谢谢。
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)发布于 2020-11-06 23:10:02
使用Id选择器#swe_maps和#swe_maps2,而不是在css中使用类选择器.leaflet-container。
library(shinydashboard)
library(leaflet)
library(tidyverse)
library(shiny)
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', '
#swe_maps {
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', '
#swe_maps2 {
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)https://stackoverflow.com/questions/64669524
复制相似问题