google_streetview: Google street view

Description Usage Arguments Examples

View source: R/google_streetview.R

Description

Displays a static street view image from Google Maps Street View Image API

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
google_streetview(
  location = NULL,
  panorama_id = NULL,
  size = c(400, 400),
  heading = NULL,
  fov = 90,
  pitch = 0,
  output = c("plot", "html"),
  response_check = FALSE,
  signature = NULL,
  key = get_api_key("streetview")
)

Arguments

location

numeric vector of lat/lon coordinates, or an address string.

panorama_id

a specific panorama ID.

size

numeric vector of length 2, specifying the output size of the image in pixels, given in width x height. For example, c(600, 400) returns an image 600 pixles wide and 400 pixles high.

heading

indicates the compass heading of the camera. Accepted values are from 0 to 360 (both 0 and 360 indicate north), 90 indicates east, 180 south and 270 west. If no heading is specified a value will be calculated that directs the camera to wards the specified location, from the point at which the closest photograph was taken.

fov

determines the horizontal field of view of the image. The field of view is expressed in degrees, with a maximum allowed value of 120. When dealing with a fixed-size viewport, as with Street View image of a set size, field of view in essence represents zoom, with small numbers indicating a higher level of zoom

pitch

specifies the up or down angle of the camera relative to the Street View vehicle. This is often, but not always, flat horizontal. Positive values angle the camera up (with 90 degrees indicating straight up); negative values angle the camera down (with -90 indicating straight down)

output

specifies whether the result should be displayed in R's viewer, or embedded as HTML inside a webpage.

response_check

logical indicating if the function should first check if the image is available. If TRUE and no image is available, a warning message is printed and no image will be downloaded. if FALSE and no image is available, a blank image will be displayed saying 'Sorry, we have no imagery here'.

signature

a digitial signature used to verify that any site generating requests using your API key is authorised to do so. See Google Documentation for further details https://developers.google.com/maps/documentation/streetview/overview

key

string. A valid Google Developers Street View Image API key

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
## Not run: 

## download and display an image
# key <- "your_api_key"
google_streetview(location = c(-37.817714, 144.96726),
    size = c(400,400), output = "plot",
    key = key)


## no response check - display 'sorry' message
google_streetview(location = c(-37.8, 144),
   size = c(400,400),
   panorama_id = NULL,
   output = "plot",
   heading = 90,
   fov = 90,
   pitch = 0,
   response_check = FALSE,
   key = key)


## embed an image of Flinders Street Station into a Shiny webpage
library(shiny)
library(googleway)

ui <- fluidPage(
  uiOutput(outputId = "myStreetview")
)

server <- function(input, output){
  key <- "your_api_key"

  output$myStreetview <- renderUI({
    tags$img(src = google_streetview(location = c(-37.817714, 144.96726),
                                     size = c(400,400), output = "html",
                                     key = key),  width = "400px", height = "400px")
  })
}

shinyApp(ui, server)


## End(Not run)

googleway documentation built on Nov. 16, 2020, 9:08 a.m.