Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Style function not working when soley add to 'feature_group_to_add' parameter #121

Closed
KeonwooChoi opened this issue Mar 7, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@KeonwooChoi
Copy link

Hello Im gonna using feature_group_to_add param rathern than add to map directly because of loading speed.

But I found that I have to add feature group to map before using st_folium. And it also causing slow speed. Here's my code

This code works, but slow

  map = folium.Map(location=[37.552213, 127.011354], zoom_start=10)
  fg = folium.FeatureGroup()
  folium.GeoJson(
            geo_json,
            style_function=lambda x:{'fillColor':'red'},
        ).add_to(fg)

  map.add_child(fg)

  out = st_folium(
      map ,
      feature_group_to_add=fg
  )

image

This code not works

  map = folium.Map(location=[37.552213, 127.011354], zoom_start=10)
  fg = folium.FeatureGroup()
  folium.GeoJson(
            geo_json,
            style_function=lambda x:{'fillColor':'red'},
        ).add_to(fg)

  out = st_folium(
      map ,
      feature_group_to_add=fg
  )

image

@csipapicsa
Copy link

csipapicsa commented Apr 1, 2023

same problem in here. When I try to load the styles, it doesnt work, but when it is written there it is ok

style=LAYERSTYLE[k]

ma.m2.add_child(layers[k].add_child(folium.GeoJson(data=files[k], style_function=lambda x: style))) # every layer has an default orange color

ma.m2.add_child(layers[k].add_child(folium.GeoJson(data=files[k], style_function=lambda x:{"fillColor": "green"}))) # this is works.

Even I get "make this notebook trusted" message

Quite strange: When I define the style dict in the "bla" it works, when I load it it is not

This is ok:
bla = {"fillColor": "green"}
ma.m2.add_child(layers[k].add_child(folium.GeoJson(data=files[k], style_function=lambda x:bla)))

This is still not:
style = LAYERSTYLE[k]
ma.m2.add_child(layers[k].add_child(folium.GeoJson(data=files[k], style_function=lambda x:style)))

@TaylerUva
Copy link

I am having the same issue. It's a deal breaker for if I'm able to use streamlit or not

@BastienGauthier
Copy link
Contributor

Same here, which prevent me from using Choropleth.

Use case : I was hoping that the "feature_group_to_add" could help me with Choropleth updates given a slider.

@randyzwitch randyzwitch added the enhancement New feature or request label Jul 7, 2023
ericnost added a commit to edgi-govdata-archiving/EEW_SDWA_NJ that referenced this issue Jul 27, 2023
integrates new "slippy" flow control, and #105 as of 7/27
fixes #106
fixes #96 (!)
fixes #92
fixes #84 (mostly; see randyzwitch/streamlit-folium#121)
fixes #70
fixes #65
addresses #63 (using marker clusters, but we still need a context note)
@patrontheo
Copy link
Contributor

Hey, @KeonwooChoi, @csipapicsa, @TaylerUva, @BastienGauthier This has been solved in the latest PR. (see #146 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants