Use folium Map as holoviews DynamicMap

163 views Asked by At

I have a folium.Map that contains custom HTML Popups with clickable URLs. These Popups open when clicking on the polygons of the map. This is a feature that doesn't seem to be possible to achieve using holoviews.

My ideal example of the final application that I want to build with holoviews/geoviews is here with the source code here, but I would like to exchange the main map with my folium Map and plot polygons instead of rasterized points. Now when I would like to create the holoviews.DynamicMap from the folium.Map, holoviews complains (of course) that the data type "map" is not accepted. Is this somehow still possible? I have found some notebook on GitHub where a holoviews plot in embedded in a folium map using a workaround that writes and reads again HTML, but it seems impossible to embed a folium map into holoviews such that other plots can be updated from this figure using Streams!?

Here is some toy data (from here) for the datasets that I use. For simplicity, let's assume I just had point data instead of polygons:

import folium as fn
def make_map():
    m = fm.Map(location=[20.59,78.96], zoom_start=5)
    green_p1 = fm.map.FeatureGroup()
    green_p1.add_child(
            fm.CircleMarker(
                [row.Latitude, row.Longitude],
                radius=10, 
                fill=True,
                fill_color=fill_color,
                fill_opacity=0.7
            )
        )
    map.add_child(green_p1)
    return map

If I understand it correctly, this needs to be tweaked now in the fashion that it can passed as the first argument to a holoviews.DynamicMap:

hv.DynamicMap(make_map, streams=my_streams) 

where my_streams are some other plots that should be updated with the extent of the folium map. Is that somehow possible or is my strategy wrong?

0

There are 0 answers