Bike Share marks its covered cities on the globe

Above the height stations draw at, the layer only said "Fly below 48 km to
a covered city" without showing which cities those are. Every system in
the registry now has a marker there: a green, white-ringed dot over its
city, 5 km up so terrain never hides it, shown only while the layer is on
and stations are not drawn.

Clicking a marker flies straight down into its city from 20 km, as an
explicit camera action through the shell's runNavigation, like News and
the weather layers. The markers belong to the layer for picking.
This commit is contained in:
Sameh Khamis committed 2026-11-17 20:30:04 -08:00
1 parent 09cead6a0e
commit 8fe4be484f
9 files changed
+285 -2

No files matched your search

+46
View File
@@ -4,7 +4,11 @@ import {
BIKESHARE_SELECTED_OVERLAY_SOURCE_ID,
BIKESHARE_SELECTED_OVERLAY_SOURCE_OPTIONS,
SELECTED_POINT_STYLE,
COVERAGE_FLY_HEIGHT_M,
} from './policy.js';
import { GBFS_CITY_REGISTRY } from './registry.js';
import { COVERAGE_ID_PREFIX } from './rendering.js';
import { cameraOf } from '../../render/rendererOf.js';
export function createSelection({
state: layerState,
@@ -139,6 +143,38 @@ export function createSelection({
* @param {object} viewer - The viewer the layer draws on.
*/
/**
* The covered city a marker id names, or null.
* @param {unknown} id
*/
function coverageCityOf(id) {
if (typeof id !== 'string' || !id.startsWith(COVERAGE_ID_PREFIX))
return null;
const cityId = id.slice(COVERAGE_ID_PREFIX.length);
return GBFS_CITY_REGISTRY.find((city) => city.id === cityId) ?? null;
}
/**
* Straight down over a covered city, low enough for its stations, as the
* shell's camera action when it gave one.
* @param {{ centerLat: number, centerLon: number }} city
*/
function flyIntoCity(city) {
const viewer = layerState._viewer;
if (!viewer) return;
const fly = () =>
cameraOf(viewer).flyTo(
{
lon: city.centerLon,
lat: city.centerLat,
height: COVERAGE_FLY_HEIGHT_M,
},
{ orientation: { heading: 0, pitch: -Math.PI / 2, roll: 0 } },
);
if (layerState._runNavigation) layerState._runNavigation(fly);
else fly();
}
function _installClickHandler(viewer) {
if (layerState._clickSubscription) return;
@@ -149,6 +185,15 @@ export function createSelection({
// Clicking the selected highlight itself — ignore (don't deselect).
if (hit.set === layerState._selectedSet?.id) return;
// A covered city's marker: fly down into it.
if (hit.set === layerState._coverageSet?.id) {
const city = coverageCityOf(hit.id);
if (city) {
flyIntoCity(city);
return;
}
}
// A station dot of this layer's own set
if (
hit.set === layerState._stationSet?.id &&
@@ -183,5 +228,6 @@ export function createSelection({
_selectStation,
_installClickHandler,
_onKeyDown,
coverageCityOf,
};
}