File size: 1,571 Bytes
d863e72
36cfca1
 
f461271
d34aea0
36cfca1
5dcdc61
36cfca1
5e2d822
5759e2a
 
 
81dff67
36cfca1
 
 
 
f8ca16c
cc0d439
36cfca1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4ce0f80
36cfca1
e133ffb
 
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
#import definitions
#from tkinter import W

import pandas as pd
import streamlit as st
import gradio as gr

#cleaning data
df = pd.read_csv('Map-City-State-Zip-Lat-Long.txt', dtype=str, sep=';') 
df["Latitude"] = df["Latitude"].astype(float)
df["Longitude"] = df["Longitude"].astype(float)


def writeToDataFrame(dataframe, name, location, latitude, longitude):
    newdf = {'Name': name, 'Location': location, 'Latitude': latitude, 'Longitude': longitude}
    dataframe = dataframe.append(newdf, ignore_index = True)
    return dataframe

st.title("Input a city and state I'll take you there! - Ex. Boston, MA")
city_and_state_string = st.text_input("Please search for a location:")

if city_and_state_string != "": 
            
    split_city_state = city_and_state_string.split(", ")
    state_name = split_city_state[1]
    city_name = split_city_state[0]
            
    #create a dataframe consisting of the correct city input
    city_df = df[df["City"] == city_name]
            
    #use the city dateframe to confirm you are using the right map
    lat = city_df[city_df["State"] == state_name]["Latitude"].values[0]
    lon = city_df[city_df["State"] == state_name]["Longitude"].values[0]
    city_list = []
    lat_list = []
    long_list = []
    city_list.append(city_name)
    lat_list.append(lat)
    long_list.append(lon)

    st.map(pd.DataFrame({'cities' : city_list, 'lat' : lat_list, 'lon' : long_list}))
    checkbox = st.checkbox("Show/Hide Latitude/Longitude")

    if checkbox: 
        st.write(city_name, "is located at: ", lat, ",", lon)