How to make geoviews tiles/map objects responsive?

Following the discussion on Simple Panel example of map/time series interaction for data cube?

How would I wrap the

gv.tile_sources.CartoDark() * gv.Points([-122.76, 49.555]).opts(alpha=0)

in order to make it responsive (sizing_mode="stretch_width") as it seems if I wrap in pn.pane.Holoviews I get the
AttributeError: 'HoloViews' object has no attribute '_plot_id'

class Example(pn.viewable.Viewer):
    def get_map(self):
        return (gv.tile_sources.CartoDark() * gv.Points([-122.76, 49.555]).opts(alpha=0)).opts(width=1000)

    def tap_series(self, x, y):
        lon, lat = to_lon_lat(x, y)
        self.figs_col.clear()
        self.figs_col.append( lon )
        return hv.Div(
            """<hr style="border-top: 1px transparent; height: 1px;">"""
        ).opts(height=5)

    def __init__(self):
        self.figs_col = pn.Column()
        self.map = self.get_map()
        self.tap_stream = hv.streams.Tap(source=self.map, x=-122.76, y=49.555)
        self.dynamic_map = hv.DynamicMap(self.tap_series, streams=[self.tap_stream])
        super().__init__()

    def view(self):
        return pn.Column(self.dynamic_map, self.figs_col)


app = Example()

template = pn.template.MaterialTemplate(
    site="Panel",
    title="MRE",
    main=[app.map, app.view],
    sidebar_width=200,
).servable()

(gv.tile_sources.CartoDark() * gv.Points([-122.76, 49.555]).opts(alpha=0)).opts(width=1000, responsive=True) maybe

Huh! I deleted my .jupyter and .local/share/jupyter and tried with responsive=True and it worked now. I wonder what that weird

AttributeError: 'HoloViews' object has no attribute '_plot_id'

error I kept getting by simply wrapping the gv.tile_sources ... in a panel.pane.HoloViews or pn.panel and others.

Mr. Andrew @ahuang11 do you thing it is worth making a clickable map widget so we don’t have to write the boilerplate code every time (Stream, DynamicMap etc.)?

Sure, maybe you can start a GitHub issue for a discussion in HoloViews, or potentially hvPlot.

1 Like

For anyone interested, follow this GitHub issue.