fix(input): no double-click follow or zoom on the map

The globe viewer's own double-click tracked a picked entity with a
position or zoomed to one without. Layers moving onto the draw port had it
re-created one by one (data/stockFollow.js); following is a click in GEV,
so the viewer's handler is removed where the viewer is made and every
re-creation goes: earthquakes, cyclones, air quality, news, perimeters,
drone airspace, ghost maps, places, radio, cables, CCTV, ALPR, launches,
bikeshare, Local ADS-B, installations, directions, trails, data packs,
annotations, the library's view and local GeoJSON. The Cockpit's own
double-click and the draw tool's finishing double-click stay.
This commit is contained in:
Sameh Khamis committed 2026-11-14 09:10:14 -08:00
1 parent bb2d22dbce
commit b86014244d
69 files changed
+94 -2797

No files matched your search

+3 -58
View File
@@ -16,11 +16,7 @@ import {
import { createHorizonCull } from '../streetLevel/view.js';
import { fromDegrees } from '../../geo/ellipsoid.js';
import { hexColor } from '../../render/color.js';
import { drawOf, findFrame, findInput } from '../../render/rendererOf.js';
import {
drawnItemTarget,
followOnDoubleClick,
} from '../../data/stockFollow.js';
import { drawOf, findFrame } from '../../render/rendererOf.js';
import { readGhostMapsKml } from './kml.js';
import {
fieldLabel,
@@ -201,8 +197,6 @@ export function createGhostMapsLayer({
let _stream = 'closed';
let _queue = Promise.resolve();
let _clickSubscription = null;
/** The follow a double-click on a placemark started, while installed. */
let _stockFollow = null;
let _rowListener = null;
let _selectedKey = null;
let _selectedCardId = null;
@@ -271,10 +265,7 @@ export function createGhostMapsLayer({
for (const [index, feature] of item.features) {
if (!isGhostMapsEventExpired(feature.dateMs, at, _ageDays)) continue;
for (const [kind, ids] of Object.entries(feature.itemIds))
if (ids.length) {
dropFollowOf(item.sets?.[kind], ids);
item.sets?.[kind]?.remove(ids);
}
if (ids.length) item.sets?.[kind]?.remove(ids);
item.features.delete(index);
if (_selectedKey === `${productId}:${index}`) clearSelection();
changed = true;
@@ -287,22 +278,9 @@ export function createGhostMapsLayer({
}
}
/**
* End a double-click's follow of an item that goes (any of `ids`, or the
* whole set), as removing its entity ended the default renderer's.
*/
function dropFollowOf(set, ids = null) {
const key = _stockFollow?.following?.key;
if (!set || !key?.startsWith(`${set.id}:`)) return;
if (!ids || ids.includes(key.slice(set.id.length + 1))) _stockFollow.stop();
}
function disposeSets(sets) {
if (!sets) return;
for (const set of Object.values(sets)) {
dropFollowOf(set);
set.dispose();
}
for (const set of Object.values(sets)) set.dispose();
}
/**
@@ -329,13 +307,6 @@ export function createGhostMapsLayer({
}
for (const pin of next.pins) pin.set = sets.icons;
next.sets = sets;
// Each set's items by id, for a double-click to follow or zoom to.
next.drawn = new Map(
Object.entries(sets).map(([kind, set]) => [
set.id,
new Map(next.items[kind].map((item) => [item.id, item])),
]),
);
}
/** The placemark a hit on one of this layer's items is, or null. */
@@ -765,32 +736,7 @@ export function createGhostMapsLayer({
});
}
/**
* A double-click follows a pin and zooms to a line or an area, as the
* default renderer did for their entities (a scene that takes no input
* has none).
*/
function installFollow() {
if (_stockFollow || !_viewer || !inputFor || !findInput(_viewer)) return;
_stockFollow = followOnDoubleClick({
viewer: _viewer,
inputFor,
name: GHOSTMAPS_LAYER_ID,
enabled: () => _enabled,
targetFor: (hit) => {
const key = hitKey(hit);
const loaded = key && _loaded.get(key.split(':')[0]);
return drawnItemTarget(
hit.set,
loaded?.drawn?.get(hit.set)?.get(hit.id),
);
},
});
}
function removeClickHandler() {
_stockFollow?.destroy();
_stockFollow = null;
_clickSubscription?.();
_clickSubscription = null;
picking?.unregisterPickOwner?.(GHOSTMAPS_LAYER_ID);
@@ -824,7 +770,6 @@ export function createGhostMapsLayer({
for (const item of _loaded.values())
for (const set of Object.values(item.sets ?? {})) set.show = true;
installClickHandler();
installFollow();
if (!_unsubscribe && typeof source.subscribe === 'function')
_unsubscribe = source.subscribe(
(catalog) => {