Skip to content

Commit 973f00b

Browse files
committed
DBC22-6776: single click on group icon takes user to next zoom level
1 parent b1f31c9 commit 973f00b

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

src/frontend/src/Components/map/handlers/click.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// External imports
22
import { fromLonLat } from "ol/proj";
3+
import { boundingExtent } from 'ol/extent';
34

45
// Internal imports
56
import { isRestStopClosed } from '../../data/restStops.js';
@@ -582,6 +583,28 @@ export const pointerClickHandler = (
582583
if (features.length) {
583584
let clickedFeature = features[0];
584585

586+
const clusterFeatures = clickedFeature.get('features');
587+
588+
if (clusterFeatures) {
589+
if (clusterFeatures.length > 1) {
590+
clusterFeatures.forEach(feature => {
591+
feature.set('hovered', false);
592+
feature.set('clicked', false);
593+
feature.setCameraStyle('static');
594+
});
595+
596+
mapView.current.animate({
597+
center: clickedFeature.getGeometry().getCoordinates(),
598+
zoom: mapView.current.getZoom() + 1,
599+
duration: 300,
600+
});
601+
602+
return;
603+
}
604+
605+
clickedFeature = clusterFeatures[0];
606+
}
607+
585608
if (!clickedFeature.get('type')) {
586609
clickedFeature = features[0].values_?.features[0];
587610
}

src/frontend/src/Components/map/layers/camerasLayer.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,10 @@ export function getCamerasLayer(cameras, projectionCode, mapContext, referenceDa
9696
text: String(size),
9797
font: 'bold 12px BC Sans',
9898
fill: new Fill({ color: textColor }),
99-
offsetX: 2,
99+
textAlign: 'center',
100+
textBaseline: 'middle',
101+
offsetX: 4,
100102
offsetY: 1,
101-
textAlign: 'left',
102103
}),
103104
});
104105
styleCache[cacheKey] = style;

0 commit comments

Comments
 (0)