Forums

web2py + folium module

I am using web2py and i need to use python folium modules for maps etc. I have install through terminal folium and but in my app iam getting a blank window with no map.

Check my app home page to understand that i mean... https://kickapoo.pythonanywhere.com/waterdrops/default/index

Any suggestions?

You've not given us a huge amount to go on :-)

First thoughts: your index_map.html is not being generated. Is this because (a) it relies on access to a non-whitelisted site? or could it be a path issue (have you set up your static stuff properly?) and is folium saving stuff in the right place?

It looks like there are a bunch of JavaScript errors in that page -- try loading it with the JavaScript console showing and you should be able to track them down.

rcs100, i cant understand that you mean by : (a) it relies on access to a non-whitelisted site

Iam saving folium generated map.html to my app/static folder. In my localhost everything works fine.... I changed it to app/private to check if is it file permission problems and i get controller/file not found error

@giles - yes, looking through the source of https://kickapoo.pythonanywhere.com/waterdrops/static/index_map.html you can see that it is successfully generating a file - it's just that the file fails to do what kickapoo wants it to do

OK: your problem is with security settings

Chrome doesn't like secure sites (like yours) that run content from insecure sites (like http://cdn.leafletjs.com/leaflet-0.5/leaflet.css)

When you run this on your localhost its clearly http://localhost, and therefore Chrome doesn't have a problem.

This is the (first) JavaScript error thrown:

[blocked] The page at 'https://kickapoo.pythonanywhere.com/waterdrops/static/index_map.html' was loaded over HTTPS, but ran insecure content from 'http://cdn.leafletjs.com/leaflet-0.5/leaflet.css': this content should also be loaded over HTTPS.

You are right... i just open my app to Safari and worked... Can you provided me any info on how to solve this for chrome? It is the first time i have to deal something like this...

The problem is that your page is set up to always load using HTTPS. If you could go to to http://kickapoo.pythonanywhere.com/waterdrops/static/index_map.html (note the "http" at the start) then it would work. However, if you try to go to that page then your site redirects you to https://kickapoo.pythonanywhere.com/waterdrops/static/index_map.html. Did you put some code in your site to do that redirect? If so, you can fix the problem by removing it.

The alternative is to change the code that loads leaflet.css to use HTTPS. Did you write that code?

giles,

I dont have any redirects to my /static/index_map.html . Index_map.html is generate by folium module and when i am using iframe tag for my default/index.html view.

leaflet.css is not write be me and also it generated by folium module.

Giles wasn't talking about the actual code of leaflet.css, he was talking about this code in the head of your HTML:

<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.5/leaflet.css" />
<script src="http://cdn.leafletjs.com/leaflet-0.5/leaflet.js"></script>

if you can change these to protocol-relative then it will work for http and for https:

<link rel="stylesheet" href="//cdn.leafletjs.com/leaflet-0.5/leaflet.css" />
<script src="//cdn.leafletjs.com/leaflet-0.5/leaflet.js"></script>

Yes i understand that Giles wrote. As i wrote in my previous comment both <link> and <script> are generated from folium library which means i cant access the code to correct the HTTPS response

Hi kickapoo,

As the Javascript keeps running ignoring the error, you could always create a file which contains the javascript Glenn has and then combine the two files after folium has created them.

Or, you could search through the folium library and change them yourself.

Thanks Robert

Ty all,

The solution based to your comments was: locate folium folder (folium.file) locate folder folium/templates change fol_template.html <link> and <script>

Cool. Glad you got that fixed.