python-visualization / folium

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

Folium Map not rendering on nbviewer. #1444

Closed navido89 closed 1 year ago

navido89 commented 3 years ago

Describe the bug Hi there. I have an issue when it comes to displaying my two folium plots inside nbviewer. It was rendering back in December but isn't now for some reason. The plots work perfectly fine when I run it on jupyter notebook, but when I paste my link to nbviewer it doesn't render anymore. I would appreciate any feedback. Please see below the link of my nbviewer and the pictures of the plots:

https://nbviewer.jupyter.org/github/navido89/DS-Job-Market-Analysis/blob/master/Indeed-DS-Jobs-Final.ipynb?flush_cache=True

F1 F2

To Reproduce

[ Include a code snippet that produces your bug. Make it standalone, we should be able to run it. ]

F1-Bug F2-Bug

[ Include a data sample or link to your data if necessary to run the code ] Please read in the pickle file before the first Seaborn plot in the jupyter notebook. Call the variable df and you can run all the plots. https://github.com/navido89/DS-Job-Market-Analysis/blob/master/Data%20Files/indeed_job_ca_clean2.pkl

Expected behavior Folium plots should display which it does. However, it doesn't render in nbviewer.

Environment (please complete the following information):

Additional context Again not worried about the file not running in jupyter notebook. The issue is when rendering it in nbviewer. I add the ipynb link from my GitHub repo.

This is the link I posted: https://nbviewer.jupyter.org/github/navido89/DS-Job-Market-Analysis/blob/master/Indeed-DS-Jobs-Final.ipynb?flush_cache=True

Could it be because of the line ?flish_cache=True ???

Interesting fact. All my other projects with a folium map render perfectly fine on nbviewer. Also, I had an issue rendering the same plot on google colab with the same tile. Not sure what the issue here. Could it be the tile?

folium is maintained by volunteers. Can you help making a fix for this issue?

Conengmo commented 3 years ago

Please complete the issue template. Which versions are you using? Can you try the latest folium version?

navido89 commented 3 years ago

@Conengmo I just completed the template. I am using the following Folium version. folium==0.11.0

Conengmo commented 3 years ago

Looking at the JS console for that nbviewer page I see this error: 09:54:04.793 Blocked loading mixed active content "http://unpkg.com/leaflet@1.3.1/dist/leaflet.js"

folium is currently using Leaflet 1.6.0, and 1.5.* a year ago. We don't reference 1.3.1 in our code anywhere. Neither do we use unpkg.com to load Leaflet. I checked the Javascript for marker cluster and it also doesn't reference that.

By the way, the most recent folium version is 0.12, could you try it with that? Make sure the whole notebook is updated? Another thing to try is to only include the folium map, so we can make sure where that error is coming from.

navido89 commented 3 years ago

So I just updated folium to 0.12, but it didn't solve the problem, unfortunately. I created a jupyter notebook file with just the map, so you can have a closer look at it. The pickle file that I read in first is on the repo in the Data folder.

If you click on the repo link below, I noticed that under the map it says: Make this Notebook Trusted to load map: File -> Trust Notebook. I haven't seen this before. I think this could be the issue. I tried fixing the problem but wasn't able to. I followed the docs.

See doc link here: https://jupyter-notebook.readthedocs.io/en/latest/notebook.html?highlight=trust#signing-notebooks

See the link of the repo with just the folium map as you requested: https://github.com/navido89/DS-Job-Market-Analysis/blob/master/CA-Analysis-Folium-Maps-Notebook.ipynb

Here is the nbviewer link of it: https://nbviewer.jupyter.org/github/navido89/DS-Job-Market-Analysis/blob/master/CA-Analysis-Folium-Maps-Notebook.ipynb

navido89 commented 3 years ago

Also just for reference. In my jupyter notebook the file is trusted and the plots work fine. Please see attached screenshots.

Screen Shot 2021-01-22 at 1 03 13 PM Screen Shot 2021-01-22 at 1 03 39 PM Screen Shot 2021-01-22 at 1 03 45 PM

Conengmo commented 1 year ago

I hope this was solved. If somebody encounters this again, please open a new issue.