Skip to content

A spy satellite simulator in your browser, except the data is real. Live open source spatial intelligence on a photorealistic 3D globe.

fix(street-level): a click picks in a 9 px window, so a thin line is hit a few pixels off

German Khokhlove2f9952867f7
diff --git a/src/layers/streetLevel/policy.js b/src/layers/streetLevel/policy.js
index c1d54b6cd..34a9400b6 100644
--- a/src/layers/streetLevel/policy.js
+++ b/src/layers/streetLevel/policy.js
@@ -13,6 +13,12 @@ export const MAPILLARY_SOURCE_METHODS = Object.freeze([
'getSequenceImages',
]);
+/**
+ * The pixel window a click picks in: coverage lines are 2.5 px wide and there
+ * is no hover cue, so a click a few pixels off still finds the line.
+ */
+export const CLICK_PICK_WINDOW_PX = 9;
+
/** Pick id of the viewer position marker. */
export const POSITION_PICK_ID = 'sl:pos';
diff --git a/src/layers/streetLevel/selection.js b/src/layers/streetLevel/selection.js
index 388c378ad..dbc97137f 100644
--- a/src/layers/streetLevel/selection.js
+++ b/src/layers/streetLevel/selection.js
@@ -1,5 +1,5 @@
import * as Cesium from 'cesium';
-import { STREET_LEVEL_LAYER_ID } from './policy.js';
+import { CLICK_PICK_WINDOW_PX, STREET_LEVEL_LAYER_ID } from './policy.js';
/** One click handler for every provider's lines and cones, and the marker. */
export function createSelection({ state, parts }) {
@@ -10,7 +10,11 @@ export function createSelection({ state, parts }) {
const viewer = state.viewer;
if (!viewer || !state.enabled) return;
if (input?.isPointerFree && !input.isPointerFree()) return;
- const picked = viewer.scene.pick(click.position);
+ const picked = viewer.scene.pick(
+ click.position,
+ CLICK_PICK_WINDOW_PX,
+ CLICK_PICK_WINDOW_PX,
+ );
const id = picking?.resolvePickId
? picking.resolvePickId(picked)
: picked?.id;