mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-20 18:22:25 +00:00
Installations: a label box takes a click only when nothing else was hit
The fallback to the label box the shared overlay paints for a site now runs only when the click hit nothing drawn (the map itself), reads the overlay in CSS pixels, and accepts the site only when its label is the one painted on top there: an aircraft or vessel, or another layer's label, over a site's label keeps its own click. Tested against the overlay's hit rects, not a stub.
This commit is contained in:
1 parent
be326fdcf4
commit
9ed6f11c58
3 files changed
+101
-13
No files matched your search
@@ -53,16 +53,22 @@ export function createSelection({
|
||||
layerState.clickSubscription = input.onClick((event) => {
|
||||
if (!layerState.enabled) return;
|
||||
// A site's dot, outline or fill, or a named marker: each draw item
|
||||
// names its installation in its `meta`. Else the label box the shared
|
||||
// overlay paints for the site (controls.findAt reads its hit rects),
|
||||
// which is what a click lands on from far out.
|
||||
// names its installation in its `meta`. Else, only when the click hit
|
||||
// nothing drawn (the map itself), the label box the shared overlay
|
||||
// paints for the site on top there (controls.findAt reads its hit
|
||||
// rects, in CSS px), which is what a click lands on from far out; an
|
||||
// aircraft or vessel drawn over a label keeps its own click.
|
||||
const hit = event.drawHit;
|
||||
const id =
|
||||
(hit?.set === parts.namedMarkers?.setId ||
|
||||
parts.rendering.ownsSet(hit?.set)
|
||||
? hit.meta?.installationId
|
||||
: null) ??
|
||||
parts.controls?.methods?.findAt?.(event.position)?.id ??
|
||||
(event.topHit
|
||||
? null
|
||||
: parts.controls?.methods?.findAt?.(
|
||||
event.screenPosition ?? event.position,
|
||||
)?.id) ??
|
||||
null;
|
||||
if (id && layerState.recordById.has(id) && id !== layerState.selectedId) {
|
||||
selectRecord(id);
|
||||
|
||||
Reference in new issue
Block a user