python-visualization / folium

Python Data. Leaflet.js Maps.
https://python-visualization.github.io/folium/
MIT License
6.86k stars 2.22k forks source link

Folium map shows fine on jupyter but does not appear on github #1072

Closed manieshablakey closed 5 years ago

manieshablakey commented 5 years ago

Hello,

I've created two folium maps. They output appears fine on my jupyter notebook (colours and all). However, when I commit them to github, the output maps no longer appear! For the 2nd map, I uncommented the last lines (m.save) but it made no difference. Some help would be much appreciated. Here's my code below.:

good loans by state

good_loans_state = pd.read_csv("output/good-loans-state.csv")

Vol of loans by state.

load map shape (US states)

state_geo = os.path.join("data", "us-states.json")

load loan data for each state

df = os.path.join("output", "good-loans-state.csv") good_loans = pd.read_csv(df)

initialize map

m = folium.Map(location=[37, -102], zoom_start=4)

set parameters for map, add color.

folium.Choropleth( geo_data=state_geo, name="choropleth", data=good_loans, columns=["addr_state", "loans_vol"], key_on="feature.id", fill_color="BuGn", fill_opacity=0.8, line_opacity=0.3, legend_name="No of good loans" ).add_to(m) folium.LayerControl().add_to(m) m

Save to html

m.save("good_loans_map.html")

jtbaker commented 5 years ago

Hello @manieshablakey - unfortunately the folium maps do not seem to render on GitHub natively. I think it likely has something to do with the site's settings on running JavaScript. However, you should be able to drop the github link to your .ipynb file into nbviewer.org and get a full dynamic output, when provided a valid folium.Map instance. Hope this helps!

manieshablakey commented 5 years ago

Oh- great. I'll do that. Thanks!!