Skip to contents

Returns the URL for a static Street View image. Useful for thumbnails, reports, or offline contexts where the interactive widget is not needed.

Usage

sv_static_url(
  lat,
  lng,
  api_key = Sys.getenv("GOOGLE_MAPS_API_KEY"),
  size = "640x400",
  heading = 0,
  pitch = 0,
  fov = 90,
  radius = 50,
  return_tag = FALSE
)

Arguments

lat

Numeric. Latitude.

lng

Numeric. Longitude.

api_key

Character. Google Maps API key. Defaults to GOOGLE_MAPS_API_KEY environment variable.

size

Character. Image dimensions as "WIDTHxHEIGHT". Max "640x640" on the free tier. Default: "640x400".

heading

Numeric. Camera heading in degrees (0-360). Default: 0.

pitch

Numeric. Camera pitch in degrees (-90 to 90). Default: 0.

fov

Numeric. Field of view in degrees (0-120). Default: 90.

radius

Numeric. Search radius in metres to find a panorama near lat/lng. Default: 50.

return_tag

Logical. If TRUE, return an HTML <img> tag instead of a bare URL string. Default: FALSE.

Value

A character URL string, or an HTML <img> tag (class "shiny.tag") when return_tag = TRUE.

Examples

# Builds the URL only; no request is made until the image is fetched.
sv_static_url(48.8584, 2.2945, api_key = "YOUR_KEY")
#> [1] "https://maps.googleapis.com/maps/api/streetview?size=640x400&location=48.8584,2.2945&heading=0&pitch=0&fov=90&radius=50&key=YOUR_KEY"

sv_static_url(48.8584, 2.2945, heading = 150, fov = 60, api_key = "YOUR_KEY")
#> [1] "https://maps.googleapis.com/maps/api/streetview?size=640x400&location=48.8584,2.2945&heading=150&pitch=0&fov=60&radius=50&key=YOUR_KEY"

if (FALSE) { # \dontrun{
# With a real key in GOOGLE_MAPS_API_KEY, open the image in a browser
browseURL(sv_static_url(48.8584, 2.2945))
} # }