jwass / mplleaflet

Easily convert matplotlib plots from Python into interactive Leaflet web maps.
BSD 3-Clause "New" or "Revised" License
521 stars 76 forks source link

Scheme agnostic URLs. #15

Closed ocefpaf closed 9 years ago

ocefpaf commented 9 years ago

I also updated leaflet to the latest release.

jwass commented 9 years ago

@ocefpaf I'm finally getting around to taking a look at this.

I often use mplleaflet locally, so just from IPython I'll make a plot and type mplleaflet.show(). I think what happens with the scheme agnostic URLs is that // expands to file:// which likely won't exist.

Thoughts?

ocefpaf commented 9 years ago

Not really. From IPython it should still expand to HTTP. IPython starts a server at http://localhost:8888, right? I think it will get expanded to file:// only it the user tries to load the HTML in the browser with the open file... option.

ocefpaf commented 9 years ago

BTW, here are examples of HTTPS and HTTP using that PR.

https://ocefpaf.github.io/python4oceanographers/blog/2014/07/14/corrida/

http://nbviewer.ipython.org/url/ocefpaf.github.com/python4oceanographers/downloads/notebooks/2014-07-14-corrida.ipynb

This also renders fine when using the notebook locally ( http://localhost:8888).

PS: Never mind the horrible CSS border on the tiles in my webpage! I am trying to fix that...

jwass commented 9 years ago

Agreed that it will work if you're using the notebook and therefore a server, but I frequently just run mplleaflet from the IPython shell or in a script outside of the IPython notebook. When you run mplleaflet.show(), it creates and saves a local html file, which gets loaded by the browser at file:///Users/jwass/_map.html or similar, which will fail to load everything.

I wonder if the right answer isn't to hardcode https wherever we know it's supported.?

ocefpaf commented 9 years ago

One could argue that mplleaflet.show() should start a web server to show the HTML instead. But maybe you are right: http://www.paulirish.com/2010/the-protocol-relative-url/

I will close this.