Creates an interactive Google Street View panorama widget that can be embedded in R Markdown documents, Shiny applications, and Xaringan presentations.
Usage
streetview(
lat,
lng,
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.
- lng
Numeric. Longitude of the location.
- 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
if (FALSE) { # \dontrun{
# Basic usage — reads API key from environment
streetview(lat = 48.8584, lng = 2.2945) # Eiffel Tower
# Custom view angle
streetview(
lat = 40.7580,
lng = -73.9855,
heading = 210,
pitch = -10,
zoom = 1
)
# Explicit API key
streetview(lat = 51.5014, lng = -0.1419, api_key = "YOUR_KEY")
} # }