I’m trying to use two crosshairs, one with PointerXY
and one with Tap
and it seems that they produce different coordinates for the same mouse position.
I’m noticing that there is a slight offset between these two. This offset can be visually seen by clicking then zooming in. Further, I have some callbacks attached to these that will extract information from a dataset at the hovered and clicked points. My expectation is that up clicking, the extracted information will be for the same point as the hover point, but that is proving not to be the case and PointerXY
and Tap
are yield different coordinates for the same mouse position.
I’m curious if anyone has any ideas on how to correct this behavior?
import geoviews as gv
import holoviews as hv
tiles = gv.tile_sources.OSM()
xlim = -20037508.34, 20037508.34
ylim = -20048966.1, 20048966.1
x0 = float((xlim[0] + xlim[-1]) / 2)
y0 = float((ylim[0] + ylim[-1]) / 2)
posxy = hv.streams.PointerXY(source=tiles, x=x0, y=y0)
clickxy = hv.streams.Tap(source=tiles, x=x0, y=y0).rename(x="x_click", y="y_click") # type: ignore
def posxy_crosshair(x, y):
kwargs = dict(color='red', line_width=1, line_dash="dashed")
return hv.HLine(y).opts(**kwargs) * hv.VLine(x).opts(**kwargs)
posch = hv.DynamicMap(posxy_crosshair, streams=[posxy])
def clickxy_crosshair(x_click, y_click):
kwargs = dict(color='black', line_width=1)
return hv.HLine(y_click).opts(**kwargs) * hv.VLine(x_click).opts(**kwargs)
clch = hv.DynamicMap(clickxy_crosshair, streams=[clickxy])
(tiles * posch * clch).opts(active_tools=['wheel_zoom'], width=600, height=600).opts(xlim=xlim, ylim=ylim)