When I was searching for a way to stop the zoom reset and flickering of the tiles when displaying spatial data, I found this solution:
https://discourse.holoviz.org/t/update-data-from-gv-polygons/1450/2 from philippjfr. It helped a lot. The only thing that doesn’t seem to work is the display of the data from the hover tool.
I have taken the code from the solution (see link above) and changed it a little bit:
import geopandas as gpd import geoviews as gv import numpy as np import panel as pn import cartopy.crs as ccrs gv.extension('bokeh') polygons = gpd.read_file(gpd.datasets.get_path('nybb')) polygons = polygons.to_crs(epsg=3857) polygons['value_1'] = [np.random.rand() for _ in polygons.index] polygons['value_2'] = [np.random.rand() for _ in polygons.index] def update_poly(some_column): col_name = 'value_' + str(some_column) polygons_tmp = polygons[[col_name, 'geometry']] return gv.Polygons(polygons_tmp, vdims=[col_name], crs=ccrs.GOOGLE_MERCATOR).opts(clim=(0, 1)) widget = pn.widgets.IntSlider(name='Choose Column', start=1, end=2) pn.Row( widget, gv.tile_sources.Wikipedia() * gv.DynamicMap(pn.bind(update_poly, widget)).opts(tools=['hover']) )
So now, when I move the slider, I can see that the color of the polygons changes according to the values from either column “value_1” or column “value_2” (I think). But the hover tool always displays the value of column “value_1”, it doesn’t update when column “value_2” is selected by the slider.
My questions: Is this expected behaviour? Because my hope was, that the value displayed by the hover tool would update too. If this is expected behaviour, can someone tell me how to get the hover tool to display an updated value?
(I ran the example code in a Jupyter-Notebook version 6.4.8, geopandas version 0.10.2, geoviews version 1.9.5, panel version 0.12.6)