49 lines
1.2 KiB
Python
49 lines
1.2 KiB
Python
#You can convert panoid to lat/lon using a free API call https://maps.googleapis.com/maps/api/streetview/metadata?pano=PANOID&key=YOURAPIKEY
|
|
|
|
|
|
#https://maps.googleapis.com/maps/api/streetview/metadata?pano=onUr8119UohoEeRXfBNArQ&key=AIzaSyDNmQaLwMoVluAJ8PMIZZyMUfp3hlbsndw
|
|
|
|
import requests
|
|
import os
|
|
import json
|
|
import webbrowser
|
|
|
|
|
|
S = requests.Session()
|
|
apikey = 'AIzaSyDNmQaLwMoVluAJ8PMIZZyMUfp3hlbsndw'
|
|
|
|
|
|
|
|
def geocheat(panoidurl):
|
|
|
|
query = requests.utils.urlparse(panoidurl).query
|
|
params = dict(x.split('=') for x in query.split('&'))
|
|
|
|
if 'panoid' in params:
|
|
panoid = params['panoid']
|
|
|
|
url = 'https://maps.googleapis.com/maps/api/streetview/metadata?pano='+panoid+'&key=AIzaSyDNmQaLwMoVluAJ8PMIZZyMUfp3hlbsndw'
|
|
dataresponse = json.loads(S.get(url).text)
|
|
#r = requests.get(url, timeout=3)
|
|
#if r.status_code == 200:
|
|
lat = dataresponse['location']['lat']
|
|
lon = dataresponse['location']['lng']
|
|
|
|
|
|
#print(lat,lon)
|
|
# print(r.content)
|
|
#print(dataresponse)
|
|
mapurl = "https://maps.google.com/maps?q=loc:" + str(lat) + "+" + str(lon)
|
|
|
|
#os.system("start \"\" + mapurl)
|
|
webbrowser.open(mapurl, new = 1)
|
|
|
|
poop = True
|
|
while poop:
|
|
|
|
cheatme = input("Enter URL with panoid: ")
|
|
geocheat(cheatme)
|
|
|
|
|
|
|