Last active
October 18, 2017 19:48
-
-
Save loganwilliams/d0b6e5b8ee36a4ae8ded4cfa725c6a5c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import xml.etree.ElementTree as ET | |
def get_pano(pano_id, api_key=your_api_key_here): | |
url_request = "https://maps.googleapis.com/maps/api/streetview?size=320x320&pano=" + pano_id + "&fov=120&heading=0&pitch=90&key=" + api_key | |
response = requests.get(url_request) | |
img = Image.open(StringIO(response.content)) | |
return img | |
# undocumented API lets us get more pano metadata | |
def outdoors(lat, lon): | |
url_request = "http://cbk0.google.com/cbk?output=xml&ll=" + str(lat) + "," + str(lon) + "&it=all" | |
response = requests.get(url_request) | |
metadata = ET.fromstring(response.content) | |
if len(metadata) > 0: | |
if ('level_id' in metadata[0].attrib): | |
return 0 | |
else: | |
return metadata[0].attrib['pano_id'] | |
else: | |
return -1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment