python-visualization / folium

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

create maps with synchronization #232

Closed PBrockmann closed 8 years ago

PBrockmann commented 9 years ago

Any interest to have synchronized view of maps. There is plugin for that: https://github.com/turban/Leaflet.Sync and a nice example http://blog.thematicmapping.org/2013/06/creating-synchronized-view-of-two-maps.html

I would need some advices on how to start this implementation.

ocefpaf commented 9 years ago

:+1:

ocefpaf commented 8 years ago

@BibMartin any idea on how to proper implement this?

In the old days of folium I would probably overload the Map() object to take a second synced_tiles kwarg. However, I am sure that the new concept of Figures and Elements allow some flexibility to implement this properly.

BibMartin commented 8 years ago

Yes, it can either be an attribute in the Map object. I would think of something like

mapA.syncWith = [mapB, mapC]

yielding

mapA.sync(mapB);
mapA.sync(mapC);

Or it can be a plugin.

mapA.add_children(plugins.SyncWith(mapB))

In both cases, I guess a function creating back-and-forth sync would be useful.

def sync_maps(mapA,mapB):
    mapA.syncWith.append(mapB)     # or the other syntax
    mapB.syncWith.append(mapA)     # or the other syntax

I'd be glad to do this as soon as v0.2 is out :wink:

ocefpaf commented 8 years ago

I'd be glad to do this as soon as v0.2 is out

Indeed! Let's put out efforts on getting v0.2 out of the door. (Says the guy who got distracted by #330 :stuck_out_tongue_winking_eye:)

BibMartin commented 8 years ago

And by https://github.com/jwass/mplleaflet/issues/35#issuecomment-171944932 :ghost:

ocefpaf commented 8 years ago

Guilty :flushed:

ocefpaf commented 8 years ago

This can be done with branca leaving folium only for single maps and branca for other rich visualizations like cross-filter and sync maps. Here is an example:

http://nbviewer.jupyter.org/github/python-visualization/folium/blob/master/examples/Features.ipynb

(Although syncing is not enabled there.)

PBrockmann commented 8 years ago

Ok thanks for the link on branca project. My target was to provide synchronous slippy maps. But also think on how to produce tiles and get a Web Map Service from calculs made in previous cells. I have worked following this idea and have achieved a functionnal python script based on gunicorn for the python WSGI server and pyferret for the graphic and calculs engine. Have a look to https://github.com/PBrockmann/wms-pyferret. Sorry for the self promotion. But it could give ideas to extend folium in this way (a graphic and calculs engine would be needed anyway). The thing also is that the gunicorn is started the time the analysis is done and that does not fit well with the notebooks approach (self describing document).

ocefpaf commented 8 years ago

That looks really cool! Thanks for sharing. I will take a look as soon as the dust settle in my day job.

Pinging @BibMartin who might also be interested.