Creates an interactive Google Street View panorama widget that can be embedded in R Markdown documents, Shiny applications, and Xaringan presentations.
Usage
streetview(
lat = NULL,
lng = NULL,
api_key = Sys.getenv("GOOGLE_MAPS_API_KEY"),
heading = 0,
pitch = 0,
zoom = 1,
pano_id = NULL,
address_control = TRUE,
fullscreen_control = TRUE,
link_control = TRUE,
pan_control = TRUE,
zoom_control = TRUE,
width = NULL,
height = NULL,
elementId = NULL
)Arguments
- lat
Numeric. Latitude of the location (-90 to 90). Optional when
pano_idis supplied.- lng
Numeric. Longitude of the location (-180 to 180). Optional when
pano_idis supplied.- api_key
Character. Your Google Maps JavaScript API key. Defaults to the environment variable
GOOGLE_MAPS_API_KEY.- heading
Numeric. Camera heading in degrees (0-360), where 0 is North. Default:
0.- pitch
Numeric. Camera pitch in degrees (-90 to 90). Negative values look down; positive values look up. Default:
0.- zoom
Numeric. Zoom level (0-3). Default:
1.- pano_id
Character. Optional panorama ID. If provided,
lat/lngare ignored and the specified panorama is loaded directly.- address_control
Logical. Show the address overlay. Default:
TRUE.- fullscreen_control
Logical. Show the fullscreen button. Default:
TRUE.- link_control
Logical. Show navigation arrows. Default:
TRUE.- pan_control
Logical. Show the pan/compass control. Default:
TRUE.- zoom_control
Logical. Show zoom buttons. Default:
TRUE.- width, height
Widget dimensions. Passed to
htmlwidgets::createWidget().heightdefaults to"400px"whenNULL.- elementId
Optional HTML element ID.
Examples
# Building a widget requires no network access; it is only rendered when
# printed in a browser, at which point a real API key is needed.
eiffel <- streetview(lat = 48.8584, lng = 2.2945, api_key = "YOUR_KEY")
# Custom view angle
times_square <- streetview(
lat = 40.7580,
lng = -73.9855,
heading = 210,
pitch = -10,
zoom = 1,
api_key = "YOUR_KEY"
)
if (FALSE) { # \dontrun{
# With GOOGLE_MAPS_API_KEY set in ~/.Renviron the key is picked up
# automatically, and printing the widget opens the panorama.
streetview(lat = 51.5014, lng = -0.1419)
} # }
