KeshavRa commited on
Commit
09b12dc
·
verified ·
1 Parent(s): ae1873a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -3
app.py CHANGED
@@ -8,6 +8,15 @@ from openai import OpenAI
8
  import folium
9
  from streamlit_folium import folium_static
10
 
 
 
 
 
 
 
 
 
 
11
  # Reference: https://github.com/sfc38/Google-Maps-API-Streamlit-App/blob/master/google_maps_app.py#L126-L135
12
  def create_map():
13
  # Create the map with Google Maps
@@ -268,10 +277,12 @@ else:
268
 
269
  # Create map for address
270
  map = create_map()
271
- geocoding_api_key = os.environ['OpenWeather_API_KEY']
 
272
  address = f"{shelter['Address']}, {shelter['City']}, CA"
273
- coordinates = get_coordinates(address, geocoding_api_key)
274
- folium.Marker(coordinates, popup=address).add_to(map)
 
275
  folium_static(map)
276
 
277
  # Create two columns
 
8
  import folium
9
  from streamlit_folium import folium_static
10
 
11
+ def geocode_address(address, api_key):
12
+ # URL encode the address
13
+ encoded_address = requests.utils.quote(address)
14
+
15
+ # Send a request to the Google Maps Geocoding API
16
+ geocode_url = f"https://maps.googleapis.com/maps/api/geocode/json?address={encoded_address}&key={api_key}"
17
+ response = requests.get(geocode_url)
18
+ data = response.json()
19
+
20
  # Reference: https://github.com/sfc38/Google-Maps-API-Streamlit-App/blob/master/google_maps_app.py#L126-L135
21
  def create_map():
22
  # Create the map with Google Maps
 
277
 
278
  # Create map for address
279
  map = create_map()
280
+
281
+ key = os.environ['GoogleAPI']
282
  address = f"{shelter['Address']}, {shelter['City']}, CA"
283
+ lat, long = geocode_address(address, key)
284
+
285
+ folium.Marker([lat, long], popup=address).add_to(map)
286
  folium_static(map)
287
 
288
  # Create two columns