Comments (3)
Did you already already find a solution for that?
I think I'm facing the same problem
from folium.
Did you already already find a solution for that? I think I'm facing the same problem
I found a workaround.
You must use folium.Choroplet and then access the underlying geojson and cmap. Here is the code I used, you can modify it with your own GeoJson dataframe:
mapita = folium.Map()
fg_lst = []
# Solamente nos interesan las columnas de data
for i, col in enumerate(regiones_data.columns):
if col in ["CUT_REG", "REGION"]:
continue
choropleth = folium.Choropleth(
geo_data=regiones,
name=col,
data=regiones_data,
columns=["CUT_REG", col],
key_on="feature.properties.CUT_REG",
fill_color="YlOrRd",
fill_opacity=0.7,
line_opacity=0.2,
legend_name=col,
highlight=True,
line_color="white",
)
folium.GeoJsonTooltip(
fields=["REGION_x", col],
aliases=[field.title() for field in ["REGION_x", col]],
style="background-color: white; color: #333333; font-family: arial; font-size: 12px; padding: 10px;",
localize=True,
).add_to(choropleth.geojson)
fg = folium.FeatureGroup(col)
choropleth.geojson.add_to(fg)
mapita.add_child(fg)
mapita.add_child(choropleth.color_scale)
mapita.add_child(BindColormap(fg, choropleth.color_scale))
fg_lst.append(fg)
GroupedLayerControl(
groups={"Groups": fg_lst},
collapsed=False,
).add_to(mapita)
mapita
from folium.
I'm trying to replicate your issue, but not succeeding so far. Can you provide a minimal, standalone code snippet that reproduces your issue?
Here's what I tried what worked for me:
m = folium.Map()
for i in range(4):
fg = folium.FeatureGroup(name=str(i)).add_to(m)
folium.GeoJson(
"https://raw.githubusercontent.com/python-visualization/folium-example-data/main/us_states.json",
name=f"geojson {i}",
highlight_function=lambda x: {
"fillOpacity": i / 10,
},
).add_to(fg)
folium.LayerControl(collapsed=False).add_to(m)
m.show_in_browser()
from folium.
Related Issues (20)
- Realtime plugin: load local GeoJson file HOT 8
- Add ability to add a dynamic text/title per frame when using TimestampedGeoJson HOT 2
- Possibility to show all points from geojson file with the realtime plugin. HOT 2
- Folium maps not displayed with Safari in Iphones HOT 1
- GeoJson style is not being applied correctly HOT 2
- Keep original size of image in CustomIcon
- NumPy 2.0 support HOT 4
- AttributeError: module 'folium' has no attribute 'plugins' HOT 1
- Marker with same ID results into broken html HOT 1
- Make Folium follow the Leaflet class hierarchy more closely HOT 4
- Add example pattern for pulling JsCode snippets from external javascript files HOT 9
- Support function objects in Leaflet options. HOT 3
- HTML does not work when run on mobile. HOT 2
- Blue Lines when using TimestampedGeoJson in Folium HOT 2
- Docs not quite representative of the real "latest" version? HOT 6
- No popup when clicking on specific icons (BeautifyIcon plugin) HOT 2
- Geocoder plugin not working in Google Chrome HOT 2
- Making a tooltip stay when clicked on a marker/shape HOT 1
- Add Code of Conduct HOT 1
- Trying to figure out why I'm getting different sets of colors with to_step() versus StepColormap() when using a list of custom bins
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from folium.