DynamicMap of tile_source flickers

Hi HoloViz! Been away for a bit, but am back into it all!

I am finally taking the plunge into using GeoViews for the first time, and I am running into issues with a dynamic map (made from overlaying some data on top of some tile sources) flickering with every update. Here is a minimal reproduction of the issue:

import geoviews as gv
import numpy as np
import pandas as pd
import panel as pn

gv.extension('bokeh')
pn.extension()

lon_min = -80.1
lon_max = -80.0

lat_min = 41.0
lat_max = 41.1

rectangles = gv.Rectangles([(lon_min-0.005, lat_min-0.005, lon_max+0.005, lat_max+0.005)]).opts(color=None)
region = gv.tile_sources.OSM() * rectangles

df = pd.DataFrame({
    'latitude': np.linspace(lat_min, lat_max, 1000),
    'longitude': np.linspace(lon_min, lon_max, 1000),
})

slider = pn.widgets.IntSlider(name='Frame', start=1, end=1000, step=1)

@pn.depends(slider)
def path(s):
    plot = gv.Points(zip(df.longitude.iloc[:s], df.latitude.iloc[:s])).opts(color='r')
    return (region * plot)

pn.Column(slider, path).servable()

As I drag the slider, the map layer flickers (the data being overlaid does not flicker). Even a single tick of the slider results in a flicker of the map. The flickering also is there without layering the data on top.

Being so new to GeoViews (less than 24 hours in!), I wonder if this is expected (due to the complexity of the tile sources). I had trouble trying to get that layer to rasterize as I thought that maybe it was constantly trying to load the tiles/zoom to the area of interest, but I could not figure that out either. Any guidance on how to get a visualization like this to work without the flickering would be much appreciated (I do not care about any region outside of the viewed area)!

You can wrap the function in a hv.DynamicMap which will only update the new part each update.

@pn.depends(slider)
def path(value):
    plot = gv.Points(zip(df.longitude.iloc[:value], df.latitude.iloc[:value])).opts(color='r')
    return (region * plot)

pn.Column(slider, hv.DynamicMap(path)).servable()

1 Like

Ty! I am clearly a little but rusty and completely ignored that I wasn’t actually using a DynamicMap :slight_smile: