我有各种各样的地址,而且我已经成功使用Google的Street View API获取了这些地址的街景。但是,我需要检索的街景图像在建筑物前没有遮挡物。使用Google Maps的街景视图,我可以看到该地址的历史(以前年份)图像,并且在某些历史图像中没有遮挡物。问题是我还没有找到一种使用API获取相同历史图像的方法。
def GetStreet(Add,SaveLoc):
base = "https://maps.googleapis.com/maps/api/streetview?size=600x300&\
pitch=0&location="
base_meta = "https://maps.googleapis.com/maps/api/streetview/\
metadata?size=600x300&&location="
geobase = "https://maps.googleapis.com/maps/api/geocode/json?address="
# we need to check if an image exists for the given address and if it
# has northeast and southwest lat/lng coord.
geo_add = geobase + urllib.request.quote(Add) + key
geoJ = requests.get(geo_add).json()
if 'bounds' in geoJ['results'][0]['geometry']:
ne = geoJ['results'][0]['geometry']['bounds']['northeast']
sw = geoJ['results'][0]['geometry']['bounds']['southwest']
meta_sw = base_meta + urllib.request.quote(str(sw['lat'])) + ',' + \
urllib.request.quote(str(sw['lng']))+ key
meta_swJ = requests.get(meta_sw).json()
meta_ne = base_meta + urllib.request.quote(str(ne['lat'])) + ',' + \
urllib.request.quote(str(ne['lng']))+ key
meta_neJ = requests.get(meta_ne).json()
if meta_neJ['status'] =='OK' and meta_swJ['status'] == 'OK':
# get the two different view points of the same address
x_ll_sw = base + urllib.request.quote(str(sw['lat'])) + ',' + \
urllib.request.quote(str(sw['lng']))+ key
img_sw = Add + "_sw.jpg"
# save the images in the 'SaveLoc' with the file name
urllib.request.urlretrieve(x_ll_sw, os.path.join(SaveLoc,img_sw))
x_ll_ne = base + urllib.request.quote(str(ne['lat'])) + ',' + \
urllib.request.quote(str(ne['lng']))+ key
img_ne = Add + "_ne.jpg"
# save the images in the 'SaveLoc' with the file name
urllib.request.urlretrieve(x_ll_ne, os.path.join(SaveLoc,img_ne))
else:
by_add = base + urllib.request.quote(Add)+ key
img_name = Add + ".jpg"
urllib.request.urlretrieve(by_add, os.path.join(SaveLoc,img_name))
else:
by_add = base + urllib.request.quote(Add)+ key
img_name = Add + ".jpg"
urllib.request.urlretrieve(by_add, os.path.join(SaveLoc,img_name))
我已经提供了有关如何使用Street View API检索图像的完整代码(上面的某些代码已从其他来源改编而成),也许可以帮助您更好地理解我的问题。如果可以检索历史街景图像,请允许我。