Use 2 dataframe in 1 map
Hello everyone
I just began to use streamlit, and I am trying to display a map with 2 sources.
Sources :
- adress_input : adress_input by the user (then geocoder to lat/long)
- df_restaurant : I have a csv with restaurant lat/long
I am trying to zoom the map within the adress_input
and to be able to see the point from df_restaurant
Is there anyway of doing this ? I have tried things but always it shows 2 maps and can not handle to merge 2 maps in 1.
Steps to reproduce
Code snippet:
import streamlit as st
import pandas as pd
from geopy.geocoders import Nominatim
## -- geocoder -- #
geolocator = Nominatim(user_agent="streamlit")
# SideNAR
st.markdown("# Main page π")
st.sidebar.markdown("# Main page π")
## -- Read raw BQ data -- ##
df = pd.read_csv("vr_extract.csv")
df.rename(columns={"lattitude": "latitude"}, inplace=True)
df.dropna(subset=['latitude', "longitude"], inplace=True)
st.map(df, zoom=12)
# Adress
adress_input = st.text_input("Adress :", "3 Rue de Montholon, 75009 Paris")
location = geolocator.geocode(adress_input)
# Create a DataFrame with latitude and longitude
if location is not None:
# Create a DataFrame with latitude and longitude
data = {'latitude': [location.latitude], 'longitude': [location.longitude]}
adress_df = pd.DataFrame(data)
# Display the address on the map
st.map(adress_df, latitude="latitude", longitude="longitude", zoom=12, use_container_width = True)
else:
st.write("Address not found. Please enter a valid address.")
If applicable, please provide the steps we should take to reproduce the error or specified behavior.
Expected behavior:
1 map which will be zoomed to the adress_input
and displayed at the same time the point from df_restaurant
Actual behavior:
2 maps : 1 zoom with adress_input
, the other displayed the point from the df_restaurant
Thanx a lot !