Skip to content

Commit

Permalink
fix: map not rendering the correct position on the departure page (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
mortennordseth authored Jan 23, 2024
1 parent d61f96e commit be942f9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/components/map/map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export type MapProps = {
} & (
| {
position: Position;
initialZoom: number;
initialZoom?: number;
}
| {
mapLegs: MapLegType[];
Expand All @@ -37,7 +37,7 @@ export function Map({ layer, onSelectStopPlace, ...props }: MapProps) {
const { t } = useTranslation();

const mapLegs = hasMapLegs(props) ? props.mapLegs : undefined;
const { position, initialZoom } = hasInitialPosition(props)
const { position, initialZoom = ZOOM_LEVEL } = hasInitialPosition(props)
? props
: { position: defaultPosition, initialZoom: ZOOM_LEVEL };
const bounds = mapLegs ? getMapBounds(mapLegs) : undefined;
Expand Down Expand Up @@ -122,8 +122,8 @@ export function Map({ layer, onSelectStopPlace, ...props }: MapProps) {

function hasInitialPosition(
a: any,
): a is { position: Position; initialZoom: number } {
return a.position && a.initialZoom;
): a is { position: Position; initialZoom?: number } {
return !!a.position;
}

function hasMapLegs(a: any): a is { mapLegs: MapLegType[] } {
Expand Down

0 comments on commit be942f9

Please sign in to comment.