rrwen / google_streetview

A command line tool and module for Google Street View Image API
https://rrwen.github.io/google_streetview
MIT License
98 stars 25 forks source link

Retrieve linked panorama points #14

Closed lmarschall closed 2 years ago

lmarschall commented 3 years ago

Hey,

is there any way to retrieve the panorama links, to access the connected waypoints of the current panorama?

rrwen commented 2 years ago

Hi @lmarschall

You can retrieve the streetview api links with the api.results object.

See:

https://rrwen.github.io/google_streetview/#api.results.save_links

lmarschall commented 2 years ago

After reading the documentation, I assume, that you get an array of links connected to the searched location of the Google API. This links can be saved with the given method. Can I use this links to retrieve another location and retrieve the affiliated connected locations as well?

rrwen commented 2 years ago

@lmarschall The links give you access to each image from the search query params.

To retrieve another location, simply change the location parameter:

# Import google_streetview for the api module
import google_streetview.api

for location in ['46.414382,10.013988', '47.414382,11.013988']:

  # Define parameters for street view api
  params = [{
    'size': '600x300', # max 640x640 pixels
    'location': location,
    'heading': '151.78',
    'pitch': '-0.76',
    'key': 'your_dev_key'
  }]

  # Create a results object
  results = google_streetview.api.results(params)

  # The links are stored in the links attribute
  print(results.links)

  # You can also save links to a file
  results.save_links('links.txt')

If you do not care about organizing the links by location, you can simply use ; to separate locations:

params = [{
  'size': '600x300', # max 640x640 pixels
  'location': '46.414382,10.013988;47.414382,11.013988', # see use of ; to separate two locations
  'heading': '151.78',
  'pitch': '-0.76',
  'key': 'your_dev_key'
}]

Also see https://rrwen.github.io/google_streetview/#multiple-arguments for panorama images.

lmarschall commented 2 years ago

Awesome, that fits my use case, thank you!