-
Notifications
You must be signed in to change notification settings - Fork 0
/
mapstesting.py
76 lines (44 loc) · 1.51 KB
/
mapstesting.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import googlemaps
import requests
from pprint import pprint
from datetime import datetime
import google_streetview.api
import google_streetview.helpers
apiKey = open("apikey.txt", "r").read()
gmaps = googlemaps.Client(key=apiKey)
geocode_result = gmaps.geocode('1600 Amphitheatre Parkway, Mountain View, CA')
# Look up an address with reverse geocoding
reverse_geocode_result = gmaps.reverse_geocode((40.714224, -73.961452))
# Request directions via public transit
now = datetime.now()
result = gmaps.directions("Bellamy",
"Louisville, KY",
mode="driving",
alternatives=True,
departure_time=now)
steps = result[0]["legs"][0]["steps"]
numOfSteps = len(steps)
stepLocations = []
for step in steps:
stepLocations.append(step["start_location"])
allLatLngs = ""
for i in range(0, len(stepLocations)):
lat = str(stepLocations[i]["lat"])
lng = str(stepLocations[i]["lng"])
if (i == 0):
string = lat + "," + lng
else:
string = ";" + lat + "," + lng
latLng = string.strip()
allLatLngs += latLng
print(allLatLngs)
params = {
'size': '600x300', # max 640x640 pixels
'location': allLatLngs,
'heading': '151.78',
'pitch': '-0.76',
'key': apiKey
}
api_list = google_streetview.helpers.api_list(params)
results = google_streetview.api.results(api_list)
results.download_links('stepimages')