# isntall the library # pip install googlemaps # pip install Pillow # import the libraries import googlemaps from GoogleMapsAPIKey import get_my_key from PIL import Image # Define the API Key. API_KEY = get_my_key() # Define the Client gmaps = googlemaps.Client(key=API_KEY) def place_search(): # Do a simple nearby search where we specify the location # in lat/lon format, along with a radius measured in meters places_result = gmaps.places_nearby(location='-33.8670522,151.1957362', radius=10000) # loop through each of the places in the results, and get the place details. for place in places_result['results']: # define the place id, needed to get place details. Formatted as a string. my_place_id = place['place_id'] # define the fields you would liked return. Formatted as a list. my_fields = ['name', 'formatted_phone_number', 'photo']
from bson import ObjectId import requests from flask_googlemaps import GoogleMaps from flask_googlemaps import Map from GoogleMapsAPIKey import get_my_key from Maps import getCurrentLocation, getZipCode app = Flask(__name__) client = MongoClient( "mongodb+srv://suminkim:[email protected]/test?retryWrites=true&w=majority" ) honey_db = client['honey_db'] # you can set key as config app.config['GOOGLEMAPS_KEY'] = get_my_key() # Initialize the extension GoogleMaps(app) class JSONEncoder(json.JSONEncoder): def default(self, o): if isinstance(o, ObjectId): return str(o) return json.JSONEncoder.default(self, o) @app.route('/') def start(): return render_template("index.html")