diff --git a/client/src/components/Map/MapViewGL.test.tsx b/client/src/components/Map/MapViewGL.test.tsx
index a5550a010..381f9906d 100644
--- a/client/src/components/Map/MapViewGL.test.tsx
+++ b/client/src/components/Map/MapViewGL.test.tsx
@@ -1768,6 +1768,35 @@ describe('MapViewGL', () => {
expect(drawn).not.toContainEqual([2.3, 48.3])
})
+ // The bubbles are DOM so they share the Leaflet map's font and hover; the canvas
+ // layers under them stay only as the hit area.
+ it('FE-COMP-MAPVIEWGL-106: every cluster draws one HTML count bubble that zooms in on a click', async () => {
+ loadOnAttach()
+ projectAtDayZoom()
+ const clusterSource = { ...geoSource(), getClusterExpansionZoom: vi.fn(() => 11) }
+ glMap.getSource.mockImplementation((id: string) => (id === 'trip-place-clusters' ? clusterSource : null))
+ const cluster = { properties: { cluster_id: 5, point_count: 12 }, geometry: { coordinates: [139.7, 35.6] } }
+ glMap.querySourceFeatures.mockImplementation((_id: string, query?: { filter?: unknown[] }) =>
+ query?.filter?.[0] === 'has'
+ // The same cluster crossing a tile edge, and a feature without a count.
+ ? [cluster, cluster, { properties: { cluster_id: 6 }, geometry: { coordinates: [1, 1] } }]
+ : [])
+
+ render()
+ await flushFrames()
+
+ const bubbles = glMarkers.created.filter(m => m.element.querySelector('.marker-cluster-custom'))
+ expect(bubbles).toHaveLength(1)
+ expect(bubbles[0].lngLat).toEqual([139.7, 35.6])
+ expect(bubbles[0].element.textContent).toBe('12')
+
+ act(() => { bubbles[0].element.dispatchEvent(new MouseEvent('click', { bubbles: true })) })
+ expect(clusterSource.getClusterExpansionZoom).toHaveBeenCalledWith(5, expect.any(Function))
+ expect(glMap.easeTo).toHaveBeenCalledWith({ center: [139.7, 35.6], zoom: 11, duration: 350 })
+ glMap.querySourceFeatures.mockReset()
+ glMap.querySourceFeatures.mockReturnValue([])
+ })
+
// One building modelled as several stops — drop the bags, check in, the museum inside
// it — puts every pin on the same spot, and all but the top one are unreachable. There
// is no spiderfy on a GL map, so the stack draws as the one pin worth seeing (#2344).
diff --git a/client/src/components/Map/MapViewGL.tsx b/client/src/components/Map/MapViewGL.tsx
index fa809c80d..88f942a8c 100644
--- a/client/src/components/Map/MapViewGL.tsx
+++ b/client/src/components/Map/MapViewGL.tsx
@@ -50,7 +50,7 @@ import { pluginsApi, type PluginMapMarker, type PluginMapLayer } from '../../api
import { DEFAULT_MAP_CENTER, DEFAULT_MAP_ZOOM } from '../../constants/mapDefaults'
import { alongShortestArc, computeMapViewport, TILE_SIZE_GL } from '../../utils/mapViewport'
import { selectedPlaceTarget } from './selectedPlaceTarget'
-import { PLACE_CLUSTER_CIRCLE_LAYER_ID, PLACE_CLUSTER_COUNT_LAYER_ID } from './placeClusterLayers'
+import { PLACE_CLUSTER_CIRCLE_LAYER_ID, PLACE_CLUSTER_COUNT_LAYER_ID, createClusterBubble } from './placeClusterLayers'
// Marker grouping for the GL map (#1385): MapLibre/Mapbox can't show the rich
// HTML photo markers *and* cluster them natively, so we feed the place points
@@ -140,12 +140,12 @@ function addPlaceClusterLayers(map: any): void {
type: 'circle',
source: PLACE_CLUSTER_SOURCE_ID,
filter: ['has', 'point_count'],
+ // Invisible: the bubble the user sees is DOM (createClusterBubble), these two
+ // layers stay as the hit area the track and route layers check a click against.
paint: {
- 'circle-color': '#111827',
- 'circle-opacity': 0.97,
+ 'circle-opacity': 0,
+ 'circle-stroke-opacity': 0,
'circle-radius': ['step', ['get', 'point_count'], 18, 10, 21, 50, 24],
- 'circle-stroke-width': 2.5,
- 'circle-stroke-color': 'rgba(255,255,255,0.9)',
},
})
map.addLayer({
@@ -158,11 +158,7 @@ function addPlaceClusterLayers(map: any): void {
'text-size': 12,
'text-allow-overlap': true,
},
- paint: {
- 'text-color': '#ffffff',
- 'text-halo-color': 'rgba(17,24,39,0.35)',
- 'text-halo-width': 1,
- },
+ paint: { 'text-opacity': 0 },
})
map.addLayer({
id: PLACE_UNCLUSTERED_LAYER_ID,
@@ -177,6 +173,31 @@ function addPlaceClusterLayers(map: any): void {
})
}
+/** Eases the map in to the zoom a cluster falls apart at. Both SDKs answer that
+ * question, one through a callback and one through a promise. */
+function expandCluster(map: ClusterMap, clusterId: unknown, coordinates: unknown): void {
+ if (clusterId == null || !Array.isArray(coordinates)) return
+ const source = map.getSource(PLACE_CLUSTER_SOURCE_ID) as ClusterSource | undefined
+ const easeToZoom = (nextZoom: number) => {
+ try { map.easeTo({ center: coordinates, zoom: nextZoom, duration: 350 }) } catch { /* noop */ }
+ }
+ try {
+ const maybeZoom = source?.getClusterExpansionZoom?.(clusterId, (err, nextZoom) => {
+ if (!err && typeof nextZoom === 'number') easeToZoom(nextZoom)
+ })
+ if (typeof maybeZoom === 'number') easeToZoom(maybeZoom)
+ else if (maybeZoom instanceof Promise) maybeZoom.then(easeToZoom).catch(() => {})
+ } catch { /* noop */ }
+}
+
+/** The two map calls `expandCluster` makes, the same on both SDKs. */
+interface ClusterMap {
+ getSource: (id: string) => unknown
+ easeTo: (options: { center: unknown[]; zoom: number; duration: number }) => void
+}
+interface ClusterSource {
+ getClusterExpansionZoom?: (id: unknown, done: (err: Error | null, zoom: number) => void) => unknown
+}
function createMarkerElement(place: Place & PlaceMarkerFlags & { category_color?: string; category_icon?: string }, photoUrl: string | null, orderNumbers: number[] | null, selected: boolean): HTMLDivElement {
// A stop that interrupts the drive gets its own small disc, decided before the photo
@@ -612,6 +633,8 @@ export function MapViewGL({
useDawarichTrailGL(mapRef.current, mapReady, dawarichTrack, dawarichSelectedDate, 'trip-route-casing', dawarichHiddenDates)
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const markersRef = useRef