Plot map with address from user input

Hi there - I am new to Streamlit and am working on an app that provides location-specific details based on an inputted address. I’ve built inputs that collect address information and are used to geocode the location. The lat lon for the field defaults are [43.6460454, -79.3791296] and is calculating correctly. What I don’t understand is why this is not plotted when the app loads or is refreshed. All I’m getting is a blank map. Any advice?

import streamlit as st
from shapely.geometry import Point, Polygon
import geopandas as gpd
import pandas as pd
import geopy

from geopy.geocoders import Nominatim
from geopy.extra.rate_limiter import RateLimiter

street = st.sidebar.text_input("Street", "75 Bay Street")
city = st.sidebar.text_input("City", "Toronto")
province = st.sidebar.text_input("Province", "Ontario")
country = st.sidebar.text_input("Country", "Canada")

geolocator = Nominatim(user_agent="GTA Lookup")
geocode = RateLimiter(geolocator.geocode, min_delay_seconds=1)
location = geolocator.geocode(street+", "+city+", "+province+", "+country)

lat = location.latitude
lon = location.longitude

map_data = pd.DataFrame({'lat': [lat], 'lon': [lon]}) 

edit: I’ve continued to tinker with this and if I add a second row of coordinates in the data frame both markers load correctly. This isn’t an ideal solution though…

Hi @stazy, welcome to the Streamlit community!

Thanks for posting a reproducible example, I’ll try it out now and get back to you with what I find.


In this case, it appears to be a bug in Streamlit (which I’ll file an issue for separately). In the console, when you run your code, there is an error message:

4.84c2bb2a.chunk.js:1 Uncaught Error: `zoom` must be supplied
    at t.default (4.84c2bb2a.chunk.js:1)
    at new t (4.84c2bb2a.chunk.js:1)
    at t.value (4.84c2bb2a.chunk.js:1)
    at e.value (4.84c2bb2a.chunk.js:1)
    at e.value (4.84c2bb2a.chunk.js:1)
    at se.emit (3.754ce885.chunk.js:1)
    at e.value (4.84c2bb2a.chunk.js:1)
    at e.value (4.84c2bb2a.chunk.js:1)
    at e.value (4.84c2bb2a.chunk.js:1)

Adding the zoom argument, which is an integer, appears to resolve the issue for a single point, zoom=12)