Skip to content

Commit

Permalink
front: select op with map when add train
Browse files Browse the repository at this point in the history
-bold pr on hover (for PRs on same track)
-select pr on map and choose track

Signed-off-by: theocrsb <theo_crosbie@yahoo.fr>
  • Loading branch information
theocrsb committed Nov 29, 2024
1 parent c98d385 commit b1c1b48
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
22 changes: 19 additions & 3 deletions front/src/common/Map/Layers/OperationalPoints.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,15 @@ interface Props {
colors: Theme;
layerOrder: number;
infraID: number | undefined;
operationnalPointId?: string;
}

export default function OperationalPoints({ colors, layerOrder, infraID }: Props) {
export default function OperationalPoints({
colors,
layerOrder,
infraID,
operationnalPointId,
}: Props) {
const point: LayerProps = {
type: 'circle',
'source-layer': 'operational_points',
Expand Down Expand Up @@ -42,7 +48,12 @@ export default function OperationalPoints({ colors, layerOrder, infraID }: Props
['concat', ' ', ['get', 'extensions_sncf_ch']],
],
],
'text-font': ['Roboto Condensed'],
'text-font': [
'case',
['==', ['get', 'id'], operationnalPointId || ''],
['literal', ['Roboto Bold']],
['literal', ['Roboto Condensed']],
],
'text-size': 12,
'text-anchor': 'left',
'text-justify': 'left',
Expand Down Expand Up @@ -100,7 +111,12 @@ export default function OperationalPoints({ colors, layerOrder, infraID }: Props
['get', 'extensions_sncf_ch'],
],
],
'text-font': ['Roboto Condensed'],
'text-font': [
'case',
['==', ['get', 'id'], operationnalPointId || ''],
['literal', ['Roboto Bold']],
['literal', ['Roboto Condensed']],
],
'text-size': 11,
'text-anchor': 'left',
'text-allow-overlap': false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ const Map = ({

const [mapIsLoaded, setMapIsLoaded] = useState(false);

const [operationnalPointId, setOperationnalPointId] = useState<string | undefined>(undefined);
const [snappedPoint, setSnappedPoint] = useState<Feature<Point> | undefined>();
const { urlLat = '', urlLon = '', urlZoom = '', urlBearing = '', urlPitch = '' } = useParams();
const dispatch = useAppDispatch();
Expand Down Expand Up @@ -169,13 +170,18 @@ const Map = ({

const onMoveGetFeature = (e: MapLayerMouseEvent) => {
if (preventPointSelection) return;
const result = getMapMouseEventNearestFeature(e, { layersId: ['chartis/tracks-geo/main'] });
const result = getMapMouseEventNearestFeature(e);
if (
result &&
result.feature.properties &&
result.feature.properties.id &&
result.feature.geometry.type === 'LineString'
(result.feature.geometry.type === 'LineString' || result.feature.geometry.type === 'Point')
) {
if (result.feature.geometry.type === 'Point') {
console.log(result.feature);
setOperationnalPointId(result.feature.properties.id);
}

setSnappedPoint({
type: 'Feature',
geometry: {
Expand All @@ -187,6 +193,7 @@ const Map = ({
},
});
} else {
setOperationnalPointId(undefined);
setSnappedPoint(undefined);
}
};
Expand Down Expand Up @@ -332,6 +339,7 @@ const Map = ({
colors={colors[mapStyle]}
layerOrder={LAYER_GROUPS_ORDER[LAYERS.OPERATIONAL_POINTS.GROUP]}
infraID={infraID}
operationnalPointId={operationnalPointId}
/>
)}

Expand Down

0 comments on commit b1c1b48

Please sign in to comment.