fix(map): make stops that share a spot reachable again

A trip that models one building as several stops — drop the bags, check in,
the museum inside the hotel — drew every pin on the same pixel, and only the
top one could be clicked, hovered or seen. Clustering is the mechanism for
exactly that: the plugin keeps children no zoom level can separate in one
cluster and fans them apart on click. disableClusteringAtZoom pinned the
group's own maximum zoom to 8, which both removed every cluster above it and
moved the only fan trigger into a zoom band a trip planner never operates in,
so the spiderfyOnMaxZoom set beside it could never fire.

The cutoff is gone. maxClusterRadius is a function of zoom instead: the same
generous radius as before in the overview, a pin's width above it, so stops
that are genuinely apart keep their own pins and a pile becomes a counted
bubble that fans open. Selecting a buried stop from the places rail now opens
the bubble it is hiding in rather than doing nothing visible, and it does that
without moving the camera, which stays the selection's own concern.

The GL renderer has no fan to open, so folding a pin there removes the only
thing that was left rather than providing a way in. It folds at a far tighter
radius — genuine coincidence, where nothing was reachable to begin with — and
draws the selected member of a pile, so the rail reaches it there too. A map
object without a projector now skips folding instead of dropping every marker.

The public share page spreads the same options and has no rail to fall back
on, which made it the worse case; it is fixed by the same change.

Closes #2344
This commit is contained in:
Maurice
2026-09-16 13:01:17 +02:00
parent 7ccc8dc03d
commit a782e0e471
9 changed files with 598 additions and 15 deletions
+28 -2
View File
@@ -27,6 +27,7 @@ import type { Day, Place, Reservation, RouteVia } from '../../types'
import type { MapHoverInfo } from './mapHover'
import { nightPauseMarker, NIGHT_PAUSE_MIN_ZOOM } from './nightPauseMarker'
import { clusterPois, poiClusterMarkup, poiClusterList, POI_CLUSTER_DETAIL_ZOOM } from './poiClusters'
import { groupCoincidentPlaces } from './coincidentPlaces'
import type { RoadtripHazard } from '@trek/shared'
import { useHazardLayerGL } from './useHazardLayerGL'
import { useDawarichTrailGL } from './useDawarichTrailGL'
@@ -229,7 +230,15 @@ interface Props {
onMapReady?: (map: any | null) => void
}
/** How eagerly place markers merge into a cluster. */
/**
* How eagerly place markers merge into a cluster.
*
* The overview band the Leaflet map clusters in as well (`CLUSTER_UNTIL_ZOOM` there),
* kept as plain numbers rather than shared constants so the GL bundle does not have to
* carry Leaflet for them. Above the cutoff supercluster hands every point back on its
* own, and the stops that share a coordinate are folded together at the pin level
* instead — see the reconcile below.
*/
const CLUSTER_RADIUS = 20
const CLUSTER_MAX_ZOOM = 8
@@ -1872,7 +1881,24 @@ export function MapViewGL({
seen.add(id)
visiblePlaces.push(place)
}
reconcileMarkers(visiblePlaces)
// Without a projection there is no way to tell which pins land on each other, so
// nothing is folded and every stop keeps the pin it has always had.
if (typeof map.project !== 'function') {
reconcileMarkers(visiblePlaces)
return
}
// Above the cluster cutoff supercluster reports every point unclustered, so stops
// on one coordinate would each get a pin and all but one of them would be buried
// (#2344). There is no spiderfy on a GL map to fan them out, so the pile draws as
// the one pin that is wanted: the selected stop when it is in there, which is what
// makes picking it from the places rail visible at all. Only pins that sit on each
// other fold — this side cannot undo a fold, hence its own tight radius.
const stacks = groupCoincidentPlaces(
visiblePlaces,
place => map.project([place.lng, place.lat]),
selectedPlaceId,
)
reconcileMarkers(stacks.map(stack => stack.lead))
}
const scheduleReconcile = () => {
if (raf !== null) return