-
-
Save ajlyons/58233833b4b5ccde08fd47810802f6f5 to your computer and use it in GitHub Desktop.
A fully functioning basic 360 viewer for Shiny (R). See
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
## Create a vector of the JPG files in the 'www' directory. | |
## We do this *outside* of ui() and server() because this only needs to be done once and only once | |
imgs_fn <- list.files("www", pattern = "JPG$|JPEG$", ignore.case = TRUE) | |
## Define the UI | |
ui <- fluidPage( | |
titlePanel("Simple 360 Photo Viewer"), | |
sidebarLayout( | |
sidebarPanel( | |
selectInput("img_fn", "Image", choices = imgs_fn, selected = NULL), | |
width = 2 | |
), | |
mainPanel( | |
uiOutput("pano_iframe") | |
) | |
) | |
) | |
server <- function(input, output) { | |
output$pano_iframe <- renderUI({ | |
## Construct the iframe URL | |
src_url <- paste0("pannellum.htm#panorama=", | |
input$img_fn, | |
"&autoLoad=true&autoRotate=-2") | |
tags$iframe(src = URLencode(src_url), width = "1200px", height = "600px") | |
}) | |
} | |
# Run the application | |
shinyApp(ui = ui, server = server) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment