をもとにナビゲーションバーのタブ私は私が望む何を以下の再現性のあるコードR光沢のある条件以前のタブ条件
Poly = data.frame(Strat = c("A","A","A","A","A","B","B","B","B","B"), long = c(174.5012, 174.5026, 174.5026, 174.5014,174.5012,174.5012 ,174.5020, 174.5020,174.5012,174.5012),lat = c(-35.84014, -35.84018, -35.84137,-35.84138,-35.84014,-35.84014,-35.84014,-35.84197,-35.84197,-35.84014))
Points = data.frame(long = c(174.5014 ,174.5017, 174.5021, 174.5023, 174.5020, 174.5017 ,174.5021 ,174.5017, 174.5021, 174.5019), lat = c(-35.84187, -35.84165, -35.84220 ,-35.84121, -35.84133, -35.84034, -35.84082, -35.84101, -35.84112, -35.84084))
library('leaflet')
library('shiny')
##### My take on Example 2
ui <- navbarPage(title = "navigation bar",
tabPanel("Home", fluidPage(bootstrapPage(
checkboxInput("check_box", label = "Click me to continue", FALSE),
## Main text
mainPanel(
tags$div()
)
))),
tabPanel("View Data",
bootstrapPage(
mainPanel(
),
leafletOutput("map", width ="100%", height = "600px")
)
)
)
server = function(input, output){
mymap <- reactive({
leaflet() %>% addTiles(urlTemplate = "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", attribution = NULL, layerId = NULL, group = NULL, options = tileOptions()) %>%
clearShapes() %>%
clearMarkers() %>%
fitBounds(lng1 = 174.5042, lat1= -35.83814,lng2= 174.5001, lat2 = -35.8424)
})
output$map <- renderLeaflet({
mymap()
})
myfun <- function(map) {
print("adding points")
map %>% clearShapes() %>%
clearControls() %>%
clearMarkers() %>%
addCircles(lng = Points$long, lat = Points$lat, color = "blue",fillOpacity = 1,radius = 1)
}
AddStrataPoly <- function(map) {
print("adding polygons")
for(i in 1:length(unique(Poly$Strat))) {
map <- map %>% addPolygons(lng = Poly[Poly$Strat == unique(Poly$Strat)[i],]$long, lat = Poly[Poly$Strat == unique(Poly$Strat)[i],]$lat, layerId = unique(Poly$Strat)[i], color = 'gray60', options = list(fillOpacity = 0.1))
}
map
}
observe({
leafletProxy("map") %>% myfun() %>% AddStrataPoly()
})
}
shinyApp(ui, server);
を持っているが、彼らが持っていない限り、ユーザーは、「データの表示」タブにクリックしないようにすることですチェックボックスをクリックしますか?タブは常に存在するのが理想的です。私は、タブフォントをグレーアウトして、この場合はチェックボックスの条件を満たしていなければ、ユーザーがクリックできないことを示します。
おかげ
私が翻訳に苦労しています[この](https://stackoverflow.com/questions/25455154/navlistpanel-make-tabs-sequentially-active-in-shiny-app) – SBista
@SBistaを見てください私の例でNavbarPageへのNavlistソリューション?あなたは助けてくれますか?それはリンクのためにthoのおかげです。 –