-
Notifications
You must be signed in to change notification settings - Fork 0
/
GoogleMapsAPIs.py
47 lines (38 loc) · 1.35 KB
/
GoogleMapsAPIs.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
import googlemaps
from googleplaces import GooglePlaces, types
class GoogleMaps:
def __init__(self):
# self.key = 'AIzaSyBSjAUvigq6Sg07ahdKUXt8P1_GYq9gOWo'
self.key = 'AIzaSyDnJ6_tO4KJL9qU8cEbq9DXTCX0W3aRgrE'
self.client = googlemaps.Client(self.key)
self.location = self.client.geolocate()['location']
self.radius = 100000
def get_places_nearby_keyword(self, keyword):
google_places = GooglePlaces(self.key)
query_result = google_places.nearby_search(lat_lng=self.location, keyword=keyword, radius=20000,
types=[types.TYPE_FOOD])
if query_result.has_attributions:
print(query_result.html_attributions)
for place in query_result.places:
print(place.name)
# print(place.geo_location)
# print(place.place_id)
place.get_details()
print(place.local_phone_number)
print('Website:', place.website)
print('Open in Google Maps:', place.url)
# Show photos of place
# for photo in place.photos:
# # 'maxheight' or 'maxwidth' is required
# photo.get(maxheight=500, maxwidth=500)
# # MIME-type, e.g. 'image/jpeg'
# photo.mimetype
# # Image URL
# photo.url
# # Original filename (optional)
# photo.filename
# # Raw image data
# photo.data
if query_result.has_next_page_token:
query_result_next_page = google_places.nearby_search(
pagetoken=query_result.next_page_token)