Search code examples
pythongoogle-mapsgoogle-street-view

Is there a way to use the Google Street View API and only return "side view"?


By side view I mean images where the camera is facing perpendicular to the street and facing the sidewalk that runs along the street. An example would be like this image:

http://cdn.timesofisrael.com/uploads/2015/12/Screen-Shot-2015-12-02-at-1.59.53-AM.png

For now I have been measuring the heading parameter explicitly with a compass for each street and that has allowed me to get side view images but this is not scaleable. Does Google Street View have some way to set this "side view" boolean in some way or is there existing implementations that can dynamically return the desired heading for a position to achieve side view? It seems like this would be a common use case/requirment so there must be a way to do this that isn't manually setting the heading by hand for each address.

Here is my code so far, you can see i am setting a "heading" parameter to the street view request (this is a number between 0 and 360), but i don't want to have to do this manually every time..

import urllib, os

myloc = "/Users/me/Desktop" 
key = "&key=" + "MYKEY" 

def GetStreet(Add,SaveLoc):
  base = "https://maps.googleapis.com/maps/api/streetview?size=1200x800&heading=3&location="
  MyUrl = base + Add + key
  fi = Add + ".jpg"
  urllib.urlretrieve(MyUrl, os.path.join(SaveLoc,fi))


Tests = []

for sampleAddress in range(488, 1501, 30):
  Tests.append(str(sampleAddress) + " Eighth Avenue, San Diego, CA 92101")

for i in Tests:
  GetStreet(Add=i,SaveLoc=myloc)

Solution

  • You can get information about where the camera was pointing (the direction the car was travelling) from the Google Maps Javascript API v3 StreetViewPov

    StreetViewPov object specification
    google.maps.StreetViewPov object specification
    A point of view object which specifies the camera's orientation at the Street View panorama's position. The point of view is defined as heading and pitch.

    Properties

    heading | Type: number
    The camera heading in degrees relative to true north. True north is 0°, east is 90°, south is 180°, west is 270°.
    pitch | Type: number
    The camera pitch in degrees, relative to the street view vehicle. Ranges from 90° (directly upwards) to -90° (directly downwards).

    (unfortunately this information isn't available in the StreetView Image API metadata)