diff --git a/src/elements/map/index.tsx b/src/elements/map/index.tsx index 4d92451..85a3a21 100644 --- a/src/elements/map/index.tsx +++ b/src/elements/map/index.tsx @@ -25,12 +25,16 @@ export const MyMap: React.FC = (props) =>{ }); const [route, setRoute] = useState() + console.log(route) + + useEffect(()=>{ + axios.get('https://api.mapbox.com/directions/v5/mapbox/walking/'+pathString+'?alternatives=true&continue_straight=true&geometries=geojson&language=en&overview=simplified&steps=true&access_token=pk.eyJ1IjoiZmlyZXNpZWh0IiwiYSI6ImNrdW9kemYzbTB4ZGkycHAxbXN2YnIzaGMifQ.G0fl-qVbecucfOvn8OtU4Q').then( + (data:any) => setRoute(data.data.routes[0].geometry) + ) + }) + + - if (route == undefined){ - axios.get('https://api.mapbox.com/directions/v5/mapbox/walking/'+pathString+'?alternatives=true&continue_straight=true&geometries=geojson&language=en&overview=simplified&steps=true&access_token=pk.eyJ1IjoiZmlyZXNpZWh0IiwiYSI6ImNrdW9kemYzbTB4ZGkycHAxbXN2YnIzaGMifQ.G0fl-qVbecucfOvn8OtU4Q').then( - (data:any) => setRoute(data.data.routes[0].geometry) - ) - }