> ## Content Index
> Fetch the complete content index at: https://blog.afi.io/llms.txt
> Use this file to discover other available public pages before exploring further.

# Add a street view image to your app with the Google Street View Static API
- URL: https://blog.afi.io/blog/add-a-street-view-image-to-your-app-with-the-google-street-view-static-api/
- Published: 2026-11-28T04:56:57.000Z
- Updated: 2026-11-28T09:40:32.000Z
- Description: Need street view in an email, PDF or app? The Google Street View Static API returns a plain image from a URL, no JavaScript needed.
- Author: Afian Anwar
- Tags: googlemaps

In this blog post, I’ll show you how to add a static Street View image to your website or app with a single HTTP request to the [Google Street View Static API](https://developers.google.com/maps/documentation/streetview?ref=blog.afi.io). Because it returns a plain image and needs no Javascript, it’s ideal for emails, PDFs and anywhere else that can’t run code. As usual, I’ll cover common use cases, walk through a worked example with [full source code](https://github.com/afilabs/google%5Fstatic%5Fstreetview?ref=blog.afi.io), and share a live demo you can try at [https://google-static-streetview.afi.dev/](https://google-static-streetview.afi.dev/?ref=blog.afi.io).

Part 1: [The complete Google Street View API guide](https://blog.afi.io/blog/the-complete-google-street-view-api-guide/)  
**Part 2: Add a street view image to your app with the Google Street View Static API (this article)**  
Part 3: Add interactive panoramas to your app using Dynamic Street View  
Part 4: Use Google Street View for free by calling the Google Maps embed API  
Part 5: Google Street View Insights: Analyze Google Street View images at scale

![](https://storage.ghost.io/c/c6/4d/c64da7e8-63a6-4cff-acdc-2782a6ebc377/content/images/2026/11/banner_3_car_by_house_mirrored.png)

[Embed a static (non-interactive) Street View panorama or thumbnail into your web pageEmbed Google Street View images with a simple URL![](https://storage.ghost.io/c/c6/4d/c64da7e8-63a6-4cff-acdc-2782a6ebc377/content/images/icon/favicon-579a74a8-3ef8-4d59-a408-6df7e38eead2.png)![](https://storage.ghost.io/c/c6/4d/c64da7e8-63a6-4cff-acdc-2782a6ebc377/content/images/thumbnail/logo512-38d95ef6-aa3c-4cf1-9716-6a298b712ade.png)](https://google-static-streetview.afi.dev/?ref=blog.afi.io)

### What is the Google Street View Static API?

The [Google Street View Static API](https://developers.google.com/maps/documentation/streetview?ref=blog.afi.io) is a web service that returns a Street View image for a given location. Street View imagery is made up of panoramas, 360 degree photos taken at points along a road or path. The API finds the panorama nearest to the your location and returns a flat image cropped from it. You can specify the location as a latitude/longitude pair, an address, or a [Google Place ID](https://developers.google.com/maps/documentation/places/web-service/place-id?ref=blog.afi.io).

### Google Street View Static API example

Here's how you get the street view image for [1800 Cornwall Avenue](https://maps.app.goo.gl/oZQC82QaLXtUbYyK8?ref=blog.afi.io) in the beautiful neighborhood of [Kitsilano](https://en.wikipedia.org/wiki/Kitsilano?ref=blog.afi.io), Vancouver.

![](https://storage.ghost.io/c/c6/4d/c64da7e8-63a6-4cff-acdc-2782a6ebc377/content/images/2026/11/Screenshot-2026-11-20-at-3.31.47---PM.png)

**Endpoint:** `GET`

[https://maps.googleapis.com/maps/api/streetview?](https://maps.googleapis.com/maps/api/streetview?size={SIZE}&location={LOCATION}&key={YOUR%5FAPI%5FKEY}&ref=blog.afi.io)  
[size={SIZE}&](https://maps.googleapis.com/maps/api/streetview?size={SIZE}&location={LOCATION}&key={YOUR%5FAPI%5FKEY}&ref=blog.afi.io)  
[location={LOCATION}&](https://maps.googleapis.com/maps/api/streetview?size={SIZE}&location={LOCATION}&key={YOUR%5FAPI%5FKEY}&ref=blog.afi.io)  
[key={YOUR\_API\_KEY}](https://maps.googleapis.com/maps/api/streetview?size={SIZE}&location={LOCATION}&key={YOUR%5FAPI%5FKEY}&ref=blog.afi.io)

**{SIZE}** specifies the output size of the image in pixels. Size is specified as `{width}x{height}` e.g. `size=600x400` returns an image 600 pixels wide, and 400 high.

**{LOCATION}** can be a text string (such as `1800 Cornwall Avenue, Vancouver`), a latitude and longitude coordinates pair (`49.2724355, -123.1455706`), or a [Place ID](https://developers.google.com/maps/documentation/places/web-service/place-id?ref=blog.afi.io) prefixed with `place_id:` (such as `place_id:EiwxODAwIENv`), and should be [URL-encoded](https://developers.google.com/maps/url-encoding?ref=blog.afi.io). 

**{YOUR\_API\_KEY}** is your Google Maps API key with the Google Street View API enabled.

There are also three optional parameters that are super useful:

![](https://storage.ghost.io/c/c6/4d/c64da7e8-63a6-4cff-acdc-2782a6ebc377/content/images/2026/11/street-view-heading-fov-pitch.png)

**{HEADING}** indicates the compass heading of the camera. Accepted values are from `0` to `360` (both values indicating North, with `90` indicating East, and `180` South). If you don't specify a heading, a value is calculated that directs the camera towards the specified `location`, from the point at which the closest photograph was taken. The Street View API finds the nearest panorama and automatically points the camera toward that address, so leaving `heading` out often gives a better result than setting it yourself.

![](https://storage.ghost.io/c/c6/4d/c64da7e8-63a6-4cff-acdc-2782a6ebc377/content/images/2026/11/image-4.png)

**{FOV}** (default 90) sets the image’s horizontal field of view in degrees, up to a maximum of 120\. Because a Street View image has a fixed size, the field of view effectively controls zoom: the smaller the number, the more zoomed in the image appears.

![](https://storage.ghost.io/c/c6/4d/c64da7e8-63a6-4cff-acdc-2782a6ebc377/content/images/2026/11/image-5.png)

**{PITCH}** (*default is* `0`) 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) while negative values angle the camera down (with `-90` indicating straight down).

**Endpoint:** `GET`

```
https://maps.googleapis.com/maps/api/streetview?size=600x300&location=1800%20Cornwall%20Avenue%2C%20Vancouver%2C%20BC%2C%20Canada&key={YOUR_API_KEY}
```

**Response**

![](https://storage.ghost.io/c/c6/4d/c64da7e8-63a6-4cff-acdc-2782a6ebc377/content/images/2026/11/Screenshot-2026-11-20-at-5.01.25---PM.png)

The response is the street view image itself (not JSON, which is how most Google Maps APIs return data). A successful request returns a JPEG (content type `image/jpeg`) at the dimensions you set with `size`, so you can drop the request URL straight into an `<img>` tag `src` attribute and have the browser render the photo directly, just like this:

```
<img
  src="https://maps.googleapis.com/maps/api/streetview?size=600x300&location=1800%20Cornwall%20Avenue%2C%20Vancouver%2C%20BC%2C%20Canada&key={YOUR_API_KEY}"
  alt="Street View of 1800 Cornwall Avenue, Vancouver, BC"
  width="600"
  height="300"
/>
```

### Retrieving panorama details with the metadata endpoint

As you can see, the Google Street View Static API only returns an image. If you want to find out when the street view image was taken, its exact GPS coordinates or its Panorama ID (`pano_id`) so that you can retrieve the same street view image at a later date, you need to call the [Metadata endpoint](https://developers.google.com/maps/documentation/streetview/metadata?ref=blog.afi.io).

**Endpoint:** `GET`

[https://maps.googleapis.com/maps/api/streetview/metadata?](https://maps.googleapis.com/maps/api/streetview/metadata?location={LOCATION}&key={GOOGLE%5FMAPS%5FAPI%5FKEY}&ref=blog.afi.io)  
[location={LOCATION}&](https://maps.googleapis.com/maps/api/streetview/metadata?location={LOCATION}&key={GOOGLE%5FMAPS%5FAPI%5FKEY}&ref=blog.afi.io)  
[key={GOOGLE\_MAPS\_API\_KEY}](https://maps.googleapis.com/maps/api/streetview/metadata?location={LOCATION}&key={GOOGLE%5FMAPS%5FAPI%5FKEY}&ref=blog.afi.io)

Just like with the Street View Static API, **{LOCATION}** can be a text string (such as `1800 Cornwall Avenue, Vancouver`), a latitude and longitude coordinates pair (`49.2724355, -123.1455706`), or a [Place ID](https://developers.google.com/maps/documentation/places/web-service/place-id?ref=blog.afi.io) prefixed with `place_id:` (such as `place_id:EiwxODAwIENv`), and should be [URL-encoded](https://developers.google.com/maps/url-encoding?ref=blog.afi.io). 

**{YOUR\_API\_KEY}** is your Google Maps API key with the Google Street View API enabled.

This is the street view metadata for the 1800 Cornwall Avenue example we used earlier.

**Endpoint:** `GET`

```
https://maps.googleapis.com/maps/api/streetview/metadata?location=1800%20Cornwall%20Avenue%2C%20Vancouver%2C%20BC%2C%20Canada&key={GOOGLE_MAPS_API_KEY}
```

**Response**

```
{
    "copyright": "© 2026 Google",
    "date": "2024-08",
    "location": {
        "lat": 49.27243602995181,
        "lng": -123.1455566626002
    },
    "pano_id": "FRV4hPQCV-Si_IZcxNRJYQ",
    "status": "OK"
}
```

The metadata endpoint is free to call, so you can use it to check whether a street view panorama exists near your location before requesting an image. If there isn't one, the response is `{ "status": "ZERO_RESULTS" }`.

### Google Street View Static API use cases

The [Street View Static API](https://developers.google.com/maps/documentation/streetview/overview?ref=blog.afi.io) costs $7 per 1,000 requests, half what you'd pay for an [interactive panorama](https://developers.google.com/maps/documentation/javascript/streetview?ref=blog.afi.io). The Static API is more than enough if your users just need a quick look at a place. A common use case is adding street view images to the stop list in a driver app for a routing or last mile delivery application. Delivery drivers, salespeople, service technicians or anyone using the app can then see exactly where to go and what the entrance looks like before they arrive, which saves time and reduces mistakes.

![](https://storage.ghost.io/c/c6/4d/c64da7e8-63a6-4cff-acdc-2782a6ebc377/content/images/2026/11/Streetview--1-.png)

In fact, the new [Search for Destinations](https://developers.google.com/maps/documentation/geocoding/search-for-destinations?ref=blog.afi.io) endpoint in the Geocoding API returns a `streetViewThumbnail` object with the Panorama ID for this exact purpose.

### Building a Google Street View explorer

In this final section, we'll use the [Google Street View Static API](https://developers.google.com/maps/documentation/streetview/overview?ref=blog.afi.io) to build an app that shows the Street View image for any address or place name you type in. As with most of my tutorials, full source code for for [google\_static\_streetview](https://github.com/afilabs/google%5Fstatic%5Fstreetview?ref=blog.afi.io) is available on GitHub. You can also play around with a live demo at [https://google-static-streetview.afi.dev/](https://google-static-streetview.afi.dev/?ref=blog.afi.io).

![](https://storage.ghost.io/c/c6/4d/c64da7e8-63a6-4cff-acdc-2782a6ebc377/content/images/2026/11/Browser-window@2x.png)

### How our code is organized

[google\_static\_streetview](https://github.com/afilabs/google%5Fstatic%5Fstreetview?ref=blog.afi.io) is a single page React app that uses [Vite](https://vite.dev/?ref=blog.afi.io) as the build tool and development server. When the user picks an address from the search box, the app looks up its latitude and longitude with the Places API, checks the free metadata endpoint to see if there's Street View imagery nearby, and if there is, requests the image from the closest panorama.

To get the app up and running quickly, I used [@vis.gl/react-google-maps](https://visgl.github.io/react-google-maps/?ref=blog.afi.io), a React library for the Maps JavaScript API. `<APIProvider/>` in `main.jsx` loads the API, and `<Map/>` and `<AdvancedMarker/>` in `App.jsx` draw the map and the marker. That takes care of the map setup in a few lines, so the rest of the code can focus on the Street View Static API.

**App.jsx**

![](https://storage.ghost.io/c/c6/4d/c64da7e8-63a6-4cff-acdc-2782a6ebc377/content/images/2026/11/image-6.png)

`App.jsx` is the app's root component, rendered by `main.jsx`. Besides drawing the map (`<Map/>`), the marker (`<AdvancedMarker/>`) and the search box (`<PlaceSearch/>`), it keeps track of two pieces of state: `place`, the location the user picked, and `isStreetViewOpen`, which controls whether the Street View card is showing.

**PlaceSearch.jsx**

![](https://storage.ghost.io/c/c6/4d/c64da7e8-63a6-4cff-acdc-2782a6ebc377/content/images/2026/11/Screenshot-2026-11-25-at-2.41.21---PM.png)

`components/PlaceSearch.jsx` holds a search box that uses [Google Places Autocomplete](https://blog.afi.io/blog/google-address-autocomplete-with-the-places-api/) to suggest places dynamically as the user types. The search box uses `PlaceAutocompleteElement`, the newer version of Place Autocomplete built on [Places API (New)](https://developers.google.com/maps/documentation/places/web-service/place-autocomplete?ref=blog.afi.io). 

Rather than attaching autocomplete to an `<input>` you create yourself, it's a ready made web component, `<gmp-place-autocomplete>`, that includes its own input box and suggestion dropdown. You add it to the page, listen for the `gmp-select` event, and fetch whichever place fields you need. The text input, search icon, clear button and suggestion dropdown all come ready-made with the `<gmp-place-autocomplete>` web component. That's one of its main benefits over building and styling your own search box. Here's how it works in detail:

When `PlaceSearch` first renders, the Places library usually hasn't loaded yet, so the effect exits early. Once `useMapsLibrary('places')` returns the library, the effect runs again and creates a `PlaceAutocompleteElement` inside the empty `<div ref={containerRef} className="PlaceSearch"/>`. 

```
/*** components/PlaceSearch.jsx ***/
import { useEffect, useRef } from "react";
import { useMap, useMapsLibrary } from "@vis.gl/react-google-maps";
import "./PlaceSearch.css";

export default function PlaceSearch({ onSelectPlace }) {
  const places = useMapsLibrary("places");
  const map = useMap();
  const containerRef = useRef(null);

  useEffect(() => {
    const container = containerRef.current;
    if (!places || !map || !container) return;

    const autocomplete = new places.PlaceAutocompleteElement();
    container.appendChild(autocomplete);
    //... rest of useEffect
  });
  //... rest of PlaceSearch

  return <div ref={containerRef} className="PlaceSearch" />;
}
```

The effect adds a listener for the `gmp-select` event, which fires when the user picks a suggestion from the dropdown. The event's `placePrediction` is converted to a `Place` object with `placePrediction.toPlace()`, and `place.fetchFields()` then requests its address and coordinates.

```
/*** components/PlaceSearch.jsx ***/
const handleSelect = async (event) => {
  const { placePrediction } = event;
  const place = placePrediction.toPlace();

  try {
    await place.fetchFields({ fields: ["formattedAddress", "location"] });
  } catch (error) {
    console.error("Could not fetch place details", error);
    return;
  }
  if (!place.location) return;

  //... onSelect code
};
autocomplete.addEventListener("gmp-select", handleSelect);
```

The place's `id`, `address` and `location` are passed to the `onSelectPlace` callback. In `App.jsx`, that's `handleSelectPlace`, which saves the place in state and opens `StreetViewCard.jsx`.

```
onSelectPlace({
  id: place.id,
  address: place.formattedAddress ?? placePrediction.text.toString(),
  location: place.location.toJSON(),
});

```

**StreetViewCard.jsx**

![](https://storage.ghost.io/c/c6/4d/c64da7e8-63a6-4cff-acdc-2782a6ebc377/content/images/2026/11/Screenshot-2026-11-27-at-3.39.20---PM.png)

The `<StreetViewCard/>` component (`components/StreetViewCard.jsx`) displays a popup info window showing the street view image for the selected address. It's a wrapper for the ever so useful `<InfoWindow/>` component from [@vis.gl/react-google-maps](https://visgl.github.io/react-google-maps/?ref=blog.afi.io). `<InfoWindow/>` also makes opening and closing simple: it opens when you render it, closes when you stop, and comes with a close button that fires `onCloseClick`. Passing the marker as the `anchor` keeps the window attached to it, even as the user pans and zooms the map.

```
/*** components/StreetViewCard.jsx ***/
return (
  <InfoWindow
    anchor={anchor}
    headerContent={<p className="StreetViewCard-title">{place.address}</p>}
    ariaLabel={`Street View of ${place.address}`}
    maxWidth={IMAGE_SIZE.width + 32}
    shouldFocus={false}
    onCloseClick={() => {
      trackEvent("card_close", { method: "button" });
      onClose();
    }}
  >
    <div className="StreetViewCard-frame">
      {status === "ok" ? (
        <img
          src={imageUrl}
          alt={`Street View of ${place.address}`}
          width={IMAGE_SIZE.width}
          height={IMAGE_SIZE.height}
          onError={markImageError}
        />
      ) : (
        <p className="StreetViewCard-message">{MESSAGES[status]}</p>
      )}
    </div>
  </InfoWindow>
);
```

Furthermore, any JSX you place inside `<InfoWindow/>` is rendered into the content area of the [info window](https://developers.google.com/maps/documentation/javascript/infowindows?ref=blog.afi.io). With the plain Maps Javascript API, you'd have to pass the content as an HTML string or a DOM node through [setContent()](https://developers.google.com/maps/documentation/javascript/reference/info-window?ref=blog.afi.io#InfoWindow.setContent), and update it by hand whenever something changed. With React the Street View card's content switches from "Loading Street View…" to the image as soon as the metadata check finishes, no additional code needed.

`StreetViewCard.jsx` displays the image with an ordinary `<img>` tag with a `src` pointing to the Street View Static API URL. The browser loads the picture straight from Google, with no extra code needed.

**useStreetViewStatus.js**

`hooks/useStreetViewStatus.js` is a hook (a reusable function that bundles React logic) that calls the Street View Static API's metadata endpoint (through `fetchStreetViewMetadata()` in `streetView.js`) to check whether Street View imagery exists near the selected location so you don't waste an API call on an image that doesn't exist. It returns one of four statuses: 

1. `checking` while it waits for a response,
2. `ok` if imagery exists,
3. `unavailable` if there's none, and
4. `error` if the request fails.

```
/*** services/useStreetViewStatus.js ***/
useEffect(() => {
  let isCancelled = false;
  const resultKey = `${lat},${lng}`;

  fetchStreetViewMetadata({ lat, lng })
    .then((metadata) => {
      if (isCancelled) return;
      if (metadata.status === "OK") {
        setResult({ key: resultKey, status: "ok" });
      } else if (metadata.status === "ZERO_RESULTS") {
        setResult({ key: resultKey, status: "unavailable" });
      } else {
        setResult({ key: resultKey, status: "error" });
      }
    })
    .catch(() => {
      if (isCancelled) return;
      setResult({ key: resultKey, status: "error" });
    });

  return () => {
    isCancelled = true;
  };
}, [lat, lng]);
```

`StreetViewCard` then uses the status to decide what to show: the Street View image when it's `ok`, or a short message for the other three. 

**streetView.js**

`services/streetView.js` contains two helper functions for the Street View Static API. `streetViewImageUrl()` builds the image URL that `<StreetViewCard/>` uses as its `<img>` source, and `fetchStreetViewMetadata()` calls the free metadata endpoint, which `useStreetViewStatus` uses to check for imagery.

```
/*** services/streetView.jsx ***/
const STREET_VIEW_API = 'https://maps.googleapis.com/maps/api/streetview'
const API_KEY = import.meta.env.VITE_GOOGLE_MAPS_API_KEY

export const IMAGE_WIDTH = 640
export const IMAGE_HEIGHT = 300

export function streetViewImageUrl(location, { width = IMAGE_WIDTH, height = IMAGE_HEIGHT } = {}) {
  const params = new URLSearchParams({
    size: `${width}x${height}`,
    location: `${location.lat},${location.lng}`,
    source: 'outdoor',
    return_error_code: 'true',
    key: API_KEY,
  })

  return `${STREET_VIEW_API}?${params}`
}

export async function fetchStreetViewMetadata(location) {
  const params = new URLSearchParams({
    location: `${location.lat},${location.lng}`,
    source: 'outdoor',
    key: API_KEY,
  })

  const response = await fetch(`${STREET_VIEW_API}/metadata?${params}`)
  if (!response.ok) {
    throw new Error(`Street View metadata request failed with HTTP ${response.status}`)
  }
  return response.json()
}
```

Because the Street View Static API returns an image rather than JSON, we don't need to worry about CORS (Cross Origin Resource Sharing) errors, backend proxies or writing asynchronous code (no need for `fetch()` or `await`).

**Deploy and run**

To test the app, simply visit [https://google-static-streetview.afi.dev/](https://google-static-streetview.afi.dev/?ref=blog.afi.io) and enter an address into the search box on the top right. If you'd like to run the app locally, fork [google\_static\_streetview](https://github.com/afilabs/google%5Fstatic%5Fstreetview?ref=blog.afi.io) on GitHub and run `npm install` to install dependencies. Start the app by running `npm run dev` then open [http://localhost:5173/](http://localhost:5173/?ref=blog.afi.io) in your browser to view it. Remember to update the `.env` files in both repos with a Google Maps API key that has both the Places API and Street View Static API enabled.

**This article was written by** [**Afi Labs**](https://afi.io/?ref=blog.afi.io)**, a** [**Google Maps Premier Partner**](https://www.afi.io/?ref=blog.afi.io) **and reseller. We build route optimization, navigation, and fleet tracking software on Google Maps, and offer volume pricing on GMP licensing.** [**Talk to an engineer**](https://www.afi.io/contact%5Fus?ref=blog.afi.io) **or** [**follow Afian on LinkedIn**](https://www.linkedin.com/in/afian-anwar/?ref=blog.afi.io)**.**

Next: Add interactive panoramas to your app using Dynamic Street View