Any other way of triggering this refresh of the polygons without necesarily binding it to a widget? Can callbacks trigger the map refresh? I’m trying something similar with points and changes are not reflected in the map until I rerun the cell or refresh the page where I’m serving the map.
Here I present an example where I try to change the color of a point when I change the value of a property on an object. The callback actually works, but the map doesn’t register the change until I refresh
#Minimum reproducible example
import panel as pn
import param
import geoviews as gv
from cartopy import crs
class Example(param.Parameterized):
loc = param.XYCoordinates(None)
num = param.Integer()
@property
def color(self):
if self.num > 0:
return 'green'
else:
return 'red'
a = Example(num=5, loc=(262953, 4802244))
b = Example(num=-3, loc=(262653, 4802344))
tiles = gv.tile_sources.OSM
def plot_example(example):
data ={'x': example.loc[0],
'y': example.loc[1],
}
point = gv.Points(data, kdims=['x', 'y'],
crs=crs.UTM(30)).opts(size=15, color=example.color)
def update_point(event):
if event.name == 'num':
point.opts(color='blue')
watcher = example.param.watch(update_point,['num'])
return point, watcher
p_a, w_a = plot_example(a)
p_b, w_b = plot_example(b)
final_map = tiles * p_a * p_b
final_map
pn.Row(final_map).show()
a.num= -22 # Here I just try to trigger the change
This callback and object refreshing method is taken from this thread regarding indicators (what got me into this discourse).
Although I present an example without a DynamicMap, casting those points into a dynamic map doesn’t work for me either, as I’m not actually changing the inputs for the object to dynamically refresh.
Any way to easily refresh the map in this instance?