Open vishal-parameswaran opened 10 months ago
I am unable to get the folium.map.fit_bounds() method to work. I can verify that this works when I use a jupyter notebook to render the map. But it does not work in streamlit. My code:
map = folium.Map(location=lat_long,zoom_start=6, tiles='cartodbpositron') map.fit_bounds(bounds=bounds) chloropeth = folium.Choropleth( geo_data='DATA/shapes/tl_2021_{}_tract.json'.format(state_code), data = merged_geo, columns=('tract_code', 'internet_broadband%'), line_opacity=0.2, key_on='feature.properties.GEOID', ) chloropeth.geojson.add_to(map) st_map = st_folium(map,use_container_width=True,height=600)
I have also tried to directly add a folium.FitBounds object to the child:
map = folium.Map(location=lat_long,zoom_start=6, tiles='cartodbpositron') fg = folium.FeatureGroup(name="State bounds") fg.add_child(folium.FitBounds(bounds)) chloropeth = folium.Choropleth( geo_data='DATA/shapes/tl_2021_{}_tract.json'.format(state_code), data = merged_geo, columns=('tract_code', 'internet_broadband%'), line_opacity=0.2, key_on='feature.properties.GEOID', ) chloropeth.geojson.add_to(map) st_map = st_folium(map,use_container_width=True,height=600,feature_group_to_add=fg)
My versions:
> pip list Package Version ----------------------------- ------------ aiohttp 3.8.6 aiosignal 1.3.1 altair 5.1.2 annotated-types 0.6.0 anyio 3.7.1 argon2-cffi 23.1.0 argon2-cffi-bindings 21.2.0 arrow 1.3.0 asttokens 2.2.1 async-lru 2.0.4 async-timeout 4.0.3 attrs 23.1.0 azure-core 1.29.5 azure-storage-blob 12.18.3 Babel 2.13.0 backcall 0.2.0 backports.functools-lru-cache 1.6.5 beautifulsoup4 4.12.2 bleach 6.1.0 blinker 1.6.3 boltons 23.0.0 branca 0.7.0 brotlipy 0.7.0 cachetools 5.3.2 census 0.8.20 certifi 2023.7.22 cffi 1.15.1 charset-normalizer 2.0.4 click 8.1.7 click-plugins 1.1.1 cligj 0.7.2 colorama 0.4.6 comm 0.1.4 conda-content-trust 0.1.3 conda-package-handling 2.1.0 conda_package_streaming 0.8.0 contourpy 1.1.1 cryptography 39.0.1 cycler 0.12.1 dataclasses-json 0.6.1 debugpy 1.6.6 decorator 5.1.1 defusedxml 0.7.1 exceptiongroup 1.1.3 executing 1.2.0 fastjsonschema 2.18.1 fiona 1.9.5 Flask 3.0.0 folium 0.14.0 fonttools 4.43.1 fqdn 1.5.1 frozenlist 1.4.0 geopandas 0.14.1 gitdb 4.0.11 GitPython 3.1.40 greenlet 3.0.0 idna 3.4 importlib-metadata 6.8.0 IProgress 0.4 ipykernel 6.21.2 ipython 8.10.0 ipython-genutils 0.2.0 ipywidgets 8.1.1 isodate 0.6.1 isoduration 20.11.0 itsdangerous 2.1.2 jedi 0.18.2 jellyfish 0.11.2 Jinja2 3.1.2 joblib 1.3.2 json5 0.9.14 jsonpatch 1.33 jsonpointer 2.1 jsonschema 4.19.1 jsonschema-specifications 2023.7.1 jupyter 1.0.0 jupyter_client 8.0.3 jupyter-console 6.6.3 jupyter_core 5.2.0 jupyter-events 0.8.0 jupyter-lsp 2.2.0 jupyter_server 2.8.0 jupyter_server_terminals 0.4.4 jupyterlab 4.0.7 jupyterlab-pygments 0.2.2 jupyterlab_server 2.25.0 jupyterlab-widgets 3.0.9 kiwisolver 1.4.5 langchain 0.0.317 langsmith 0.0.46 libmambapy 1.4.1 markdown-it-py 3.0.0 MarkupSafe 2.1.3 marshmallow 3.20.1 matplotlib 3.8.0 matplotlib-inline 0.1.6 mdurl 0.1.2 menuinst 1.4.19 mistune 3.0.2 multidict 6.0.4 mypy-extensions 1.0.0 nbclient 0.8.0 nbconvert 7.9.2 nbformat 5.9.2 nest-asyncio 1.5.6 notebook 7.0.6 notebook_shim 0.2.3 numpy 1.26.1 openai 0.28.1 overrides 7.4.0 packaging 23.0 pandas 2.1.1 pandocfilters 1.5.0 parso 0.8.3 pickleshare 0.7.5 Pillow 10.1.0 pip 23.3.1 platformdirs 3.0.0 pluggy 1.0.0 predictionguard 1.4.2 prometheus-client 0.17.1 prompt-toolkit 3.0.37 protobuf 4.25.1 psutil 5.9.4 pure-eval 0.2.2 pyarrow 14.0.1 pycosat 0.6.4 pycparser 2.21 pydantic 2.4.2 pydantic_core 2.10.1 pydeck 0.8.0 Pygments 2.14.0 pyOpenSSL 23.0.0 pyparsing 3.1.1 pyproj 3.6.1 PySocks 1.7.1 python-dateutil 2.8.2 python-json-logger 2.0.7 pytz 2023.3.post1 pywin32 305 pywinpty 2.0.12 PyYAML 6.0.1 pyzmq 25.0.0 qtconsole 5.4.4 QtPy 2.4.0 referencing 0.30.2 requests 2.31.0 rfc3339-validator 0.1.4 rfc3986-validator 0.1.1 rich 13.7.0 rpds-py 0.10.6 ruamel.yaml 0.17.21 scikit-learn 1.3.1 scipy 1.11.3 seaborn 0.13.0 Send2Trash 1.8.2 setuptools 68.2.2 shapely 2.0.2 six 1.16.0 smmap 5.0.1 sniffio 1.3.0 soupsieve 2.5 SQLAlchemy 2.0.22 stack-data 0.6.2 streamlit 1.28.2 streamlit-folium 0.16.0 tabulate 0.9.0 tenacity 8.2.3 terminado 0.17.1 threadpoolctl 3.2.0 tinycss2 1.2.1 toml 0.10.2 toolz 0.12.0 tornado 6.2 tqdm 4.65.0 traitlets 5.9.0 types-python-dateutil 2.8.19.14 typing_extensions 4.8.0 typing-inspect 0.9.0 tzdata 2023.3 tzlocal 5.2 uri-template 1.3.0 urllib3 1.26.16 us 3.1.1 validators 0.22.0 watchdog 3.0.0 wcwidth 0.2.6 webcolors 1.13 webencodings 0.5.1 websocket-client 1.6.4 Werkzeug 3.0.1 wheel 0.41.2 widgetsnbextension 4.0.9 win-inet-pton 1.1.0 xgboost 2.0.2 yarl 1.9.2 zipp 3.17.0 zstandard 0.19.0
Can you provide a link to the data you are using (if its public)?
Hey, got the same thing once updated the Streamlit version. I'll try to set up a few examples and share them.
I am unable to get the folium.map.fit_bounds() method to work. I can verify that this works when I use a jupyter notebook to render the map. But it does not work in streamlit. My code:
I have also tried to directly add a folium.FitBounds object to the child:
My versions: