Skip to content

Commit 9200f85

Browse files
committed
add basic tour tab with text box
1 parent 6d85e6c commit 9200f85

File tree

4 files changed

+72
-5
lines changed

4 files changed

+72
-5
lines changed

0_utils.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,4 @@ download_data_files <- list(
8888

8989
dropdown_width <- "100%"
9090

91-
citation <- "iTRAQI: injury Treatment & Rehabilitation Accessibility Queensland Index version 1.2"
91+
citation <- "iTRAQI: injury Treatment & Rehabilitation Accessibility Queensland Index version 1.2"

4_tour.R

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
tour_text <- list(
2+
c("text 1"),
3+
c("text 2"),
4+
c("text 3"),
5+
c("text 5"),
6+
c("text 6")
7+
)
8+
9+
n_tour_windows <- length(tour_text)

server.R

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,42 @@ library(leaflet)
22
library(dplyr)
33

44
function(input, output, session) {
5-
rvs <- reactiveValues(to_load=NULL, map=NULL, to_load_rehab=NULL, map_rehab=NULL, map_complete=FALSE, map_rehab_complete=FALSE)
5+
rvs <- reactiveValues(to_load=NULL, map=NULL, to_load_rehab=NULL, map_rehab=NULL, map_complete=FALSE, map_rehab_complete=FALSE, map_tour=NULL, tour_tab=1)
6+
7+
output$map_tour <- renderLeaflet({
8+
rvs$map_tour <-
9+
leaflet(options=leafletOptions(minZoom=5)) %>%
10+
setMaxBounds(lng1 = 115, lat1 = -45.00, lng2 = 170, lat2 = -5) %>%
11+
addSearchOSM(options=searchOptions(moveToLocation=FALSE, zoom=NULL)) %>%
12+
addMapPane(name = "layers", zIndex = 200) %>%
13+
addMapPane(name = "maplabels", zIndex = 400) %>%
14+
addMapPane(name = "markers", zIndex = 205) %>%
15+
addProviderTiles("CartoDB.VoyagerNoLabels") %>%
16+
addProviderTiles("CartoDB.VoyagerOnlyLabels",
17+
options = leafletOptions(pane = "maplabels"),
18+
group = "map labels")
19+
rvs$map_tour
20+
})
21+
22+
output$nextButtonControl <- renderUI({
23+
if(rvs$tour_tab != n_tour_windows) actionButton("nextButton", "Next") else NULL
24+
})
25+
26+
output$backButtonControl <- renderUI({
27+
if(rvs$tour_tab != 1) actionButton("backButton", "Back") else NULL
28+
})
29+
30+
observeEvent(input$nextButton, {
31+
rvs$tour_tab <- rvs$tour_tab + 1
32+
})
33+
34+
observeEvent(input$backButton, {
35+
rvs$tour_tab <- rvs$tour_tab - 1
36+
})
37+
38+
output$tourText <- renderUI({
39+
HTML(tour_text[[rvs$tour_tab]])
40+
})
641

742
output$map <- renderLeaflet({
843
rvs$map <-

ui.R

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,36 @@ source("0_utils.R")
1818
source("1_functions.R")
1919
source("2_pallettes.R")
2020
source("3_load_data.R")
21+
source("4_tour.R")
22+
# styles.css from https://github.com/rstudio/shiny-examples/tree/main/063-superzip-example
2123

22-
navbarPage("iTRAQI", id="nav",
23-
24+
navbarPage(
25+
"iTRAQI", id="nav",
26+
27+
tabPanel(
28+
"tour",
29+
div(class="outer",
30+
tags$head(
31+
includeCSS("styles.css")
32+
),
33+
leafletOutput("map_tour", width="100%", height="100%"),
34+
absolutePanel(
35+
id = "tour_controls", class = "panel panel-default", fixed = TRUE,
36+
draggable = TRUE, top=80, left = "auto", right = 10, bottom = "auto",
37+
width = 330, height = 350,
38+
splitLayout(
39+
cellWidths = 270,
40+
uiOutput("backButtonControl"),
41+
uiOutput("nextButtonControl")
42+
),
43+
uiOutput("tourText")
44+
)
45+
)
46+
),
47+
2448
tabPanel("Main map",
2549
div(class="outer",
2650
tags$head(
27-
# styles.css from https://github.com/rstudio/shiny-examples/tree/main/063-superzip-example
2851
includeCSS("styles.css")
2952
),
3053
leafletOutput("map", width="100%", height="100%"),

0 commit comments

Comments
 (0)