Skip to content
This repository has been archived by the owner on May 4, 2024. It is now read-only.

Commit

Permalink
Show the Roads on the map
Browse files Browse the repository at this point in the history
  • Loading branch information
Seb-sti1 committed Oct 11, 2023
1 parent 4e8280c commit d0202d8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { render, screen } from '@testing-library/react';
import MapWrapper from './MapWrapper';

// TODO: fix this test (create a mock lib for axios)
test('Check subcomponent of mapwrapper', () => {
render(<MapWrapper />);

Expand Down
13 changes: 12 additions & 1 deletion frontend/src/Components/Map/MapWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ import {

import '../../css/map.css';
import { MAP_OPTIONS } from './constants';
import React, { FC } from 'react';
import React, { FC, useEffect, useState } from 'react';
import Selector from './Inputs/Selector';
import { IRoad } from '../../models/path';
import { getRoads } from '../../queries/road';
import Roads from './Roads';

/**
* properties
Expand All @@ -24,6 +27,13 @@ interface IMapWrapper {
const MapWrapper: FC<IMapWrapper> = ({ children }) => {
const { center, zoom, minZoom, maxZoom, scaleWidth } = MAP_OPTIONS;

const [roads, setRoads] = useState<IRoad[]>();

// get the actual roads
useEffect(() => {
getRoads(setRoads);
}, []);

return (
<>
<Selector
Expand All @@ -45,6 +55,7 @@ const MapWrapper: FC<IMapWrapper> = ({ children }) => {
attribution='&copy; <a href="https://osm.org/copyright">OpenStreetMap</a> contributors'
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
/>
<Roads roads={roads} />
<ZoomControl position="topright" />
<ScaleControl
imperial={false}
Expand Down

0 comments on commit d0202d8

Please sign in to comment.