Google Street View Container inside Brilliant App

I am trying to create a web application with integrated Google Street View using the RStudio Shiny library; but could not get a view of the street to display in the application. I used an example of JavaScript and HTML: https://developers.google.com/maps/documentation/javascript/examples/streetview-embed which I insert here:

<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Street View containers</title> <style> html, body, #map-canvas { height: 100%; margin: 0px; padding: 0px } </style> <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true"></script> <script> function initialize() { var bryantPark = new google.maps.LatLng(37.869260, -122.254811); var panoramaOptions = { position: bryantPark, pov: { heading: 165, pitch: 0 }, zoom: 1 }; var myPano = new google.maps.StreetViewPanorama( document.getElementById('map-canvas'), panoramaOptions); myPano.setVisible(true); } google.maps.event.addDomListener(window, 'load', initialize); </script> </head> <body> <div id="map-canvas"></div> </body> </html> 

My ui and server scripts:

ui.R

 shinyUI(fluidPage( titlePanel("Google StreetView"), mainPanel( uiOutput("inc") ) )) 

and

server.R

 library(shiny) shinyServer(function(input, output) { getPage<-function() { return(includeHTML("googleStreetViewContainer.html")) } output$inc<-renderUI({getPage()}) }) 

I tried several different versions of the ui.R and server.R files, using includeHTML directly in the ui.R file, not defining the getPage function, and also using the $ script tags in the ui.R file.

I did not have any errors, but Street View is not a rendering. Any ideas?

+2
source share
1 answer

You can do this with my googleway and a valid Google Maps API key

In Shiny, you call renderGoogle_map() in the server and google_mapOutput() in the UI to load the graph.

Then google_map() run the map. When it opens, you can access satellite / street view, as usual, on a Google map.

 library(shiny) library(shinydashboard) library(googleway) df <- data.frame(lat = -37.817714, lon = 144.967260, info = "Flinders Street Station") map_key <- "your_api_key_here" ui <- dashboardPage( dashboardHeader(), dashboardSidebar(), dashboardBody( box( google_mapOutput("myMap") ) ) ) server <- function(input, output){ output$myMap <- renderGoogle_map({ google_map(location = c(df$lat, df$lon), key = map_key, search_box = T) }) } shinyApp(ui, server) 

enter image description here

+1
source

All Articles