I'm wondering if someone better than I am at R Shiny could tell me if the following is possible (it may not be, but I'd like to know if not).
Question: Can I open both a google map and interactive streetview in Shiny?
Why I want to do this:
I have a programmed google map coming from the googleway package shiny integration. It looks as below (code at the bottom):
In my shiny app, I can click and drag the streetview guy in the from the icon in the corner:
I'd like to jump straight into this street view on an action button or tab click instead of making the user do the drag and drop process, so that I can have the map in one shiny tab and directly into the interactive streetview in another tab, or better yet have the map and streetview side by side as in (link here: https://developers.google.com/maps/documentation/javascript/examples/streetview-simple).
Is there a way to do this?
I am also looking into googleway package to see if there is another way, but as far as I can tell I can get into an interactive panorama but not street view directly. I am also looking into the possibility of using the html integration in shiny to go directly into Street View service.
Code (simplified, but tested):
library(googleway)
library(shiny)
gpscoordlat <- 39.647806
gpscoordlon <- -104.940230
markerpointsplace <- data.frame(
lat=c(gpscoordlat),
lon=c(gpscoordlon)
)
ui <- fluidPage(google_mapOutput("map"))
server <- function(input, output, session){
###Use Your API key here###
api_key <- "GoogleAPIKeyHere"
output$map <- renderGoogle_map({
google_map(location=c(gpscoordlat, gpscoordlon), key= api_key, zoom=15) %>%
add_markers(data=markerpointsplace , update_map_view= FALSE)
})
}
shinyApp(ui, server)
This functionality is currently under development. Progress can be tracked directly on github, but I will endeavour to update this post as I go along.
You can install the development version using
devtools::install_github("SymbolixAU/googleway")
Here's an example of two maps, both controlled by the same street-view 'pegman'.
Note the two UI outputs, the standard map
output, and another one I've called pano
. This pano
is then used in the split_view
argument to google_map()
library(shiny)
library(shinydashboard)
library(googleway)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
box(width = 6,
google_mapOutput(outputId = "map")
),
box(width = 6,
google_mapOutput(outputId = "pano")
)
)
)
server <- function(input, output) {
set_key("map_api_key")
output$map <- renderGoogle_map({
google_map(location = c(-37.817386, 144.967463),
zoom = 12,
split_view = "pano")
})
}
shinyApp(ui, server)