From 1175cc57f5bb09f70bf4e8e64bb62edf77630e0f Mon Sep 17 00:00:00 2001 From: Emmy D'Anello Date: Fri, 11 Aug 2023 21:11:31 +0200 Subject: [PATCH] Search airports and draw the departure and the arrival --- client/src/App.js | 71 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 57 insertions(+), 14 deletions(-) diff --git a/client/src/App.js b/client/src/App.js index 9b7e7ab..54c93e2 100644 --- a/client/src/App.js +++ b/client/src/App.js @@ -1,26 +1,69 @@ -import {MapContainer, Marker, Popup, TileLayer} from 'react-leaflet' +import {useState} from "react" + +import {Icon} from 'leaflet' +import {Polyline, MapContainer, Marker, TileLayer} from 'react-leaflet' import './App.css'; -function Map() { +function Map({dep, arr}) { + const redIcon = new Icon({ + iconUrl: "https://raw.githubusercontent.com/pointhi/leaflet-color-markers/master/img/marker-icon-red.png", + iconSize: [25, 41], + iconAnchor: [12, 41], + popupAnchor: [1, -34], + shadowSize: [41, 41] + }) + const greenIcon = new Icon({ + iconUrl: "https://raw.githubusercontent.com/pointhi/leaflet-color-markers/master/img/marker-icon-green.png", + iconSize: [25, 41], + iconAnchor: [12, 41], + popupAnchor: [1, -34], + shadowSize: [41, 41] + }) return ( - - - - - A pretty CSS3 popup.
Easily customizable. -
-
+ + + + + ) } -function App() { +function AirportSearch({name, updateFun}) { + const [airports, setAirports] = useState([]) + + function autocomplete(event) { + const target = event.target + const value = target.value + fetch(`/api/airports?search=${value}`).then(resp => resp.json()).then(setAirports) + } + return <> - + + {airports.map(airport => <> + + )} + + + + +} + +function App() { + const [dep, setDep] = useState([0, 0]) + const [arr, setArr] = useState([0, 0]) + + return <> + + + }