opengeos/leafmap

markers not properly added on streamlit

Closed this issue · 2 comments

Hello!
I'm trying to visualize points on a map. The script works and renders as expected on a jupyter notebook, but not when I move it to streamlit. Please look at the reproductible example below.

Environment Information

  • leafmap version: 0.41.5
  • Python version: 3.12.4
  • Operating System: OS

Description

Not sure if this is an isue for leafmap, thanks for any guidance.
Also, I'm using streamlit 1.40.2

What I Did

import streamlit as st
import leafmap 
import geopandas as gpd
import pandas as pd
from shapely import Point

cities = pd.read_csv("https://raw.githubusercontent.com/giswqs/leafmap/master/examples/data/us_cities.csv")

geometry = [Point(xy) for xy in zip(cities['longitude'], cities['latitude'])]

cities = gpd.GeoDataFrame(cities, geometry = geometry, crs = 'epsg:4326')

m = leafmap.Map(center=[40, -100], zoom=4)
m.add_data(cities,
    layer_name = "Regions",
    column = "region",
    categories=['West', 'South', 'Midwest', 'Northeast'],
    colors=['#a6611a','#dfc27d','#80cdc1','#018571'],
     categorical = True, 
      legend_position ='bottomright',
        style = {
            "stroke": True,
            "color": "gray",
            "weight": .5,
            "opacity": .5,
            "fill": True,               
            "fillOpacity": 0.5,           
        }
)
m.to_streamlit(height=700)

Streamlit does not support ipyleaflet. You need to use the folium backend

import leafmap.foliumap as leafmap

Thanks so much for your answer. I replaced the import line but it still doesn't work. Should I do somesthing aditional? also closing it because it's not a leafmap issue.