diff --git a/src/components/ParkingOnTheMap.tsx b/src/components/ParkingOnTheMap.tsx index 06d7b0d..74ba55e 100644 --- a/src/components/ParkingOnTheMap.tsx +++ b/src/components/ParkingOnTheMap.tsx @@ -76,10 +76,16 @@ function ParkingOnTheMap({ parking }) { if (stateMap) return; // Get coords from parking variable - const coords = parking.Coordinaten + let coords = parking.Coordinaten ? parking.Coordinaten.split(",").map((coord: any) => Number(coord)) : null; // I.e.: 52.508011,5.473280; + if (coords[0] < -90 || coords[0] > 90 || coords[1] < -180 || coords[1] > 180) { + console.log("***** invalid coordinates for parking", parking.Title, coords); + coords = [52.508011, 5.47328]; + return; + } + // otherwise, create a map instance const mapboxMap = new maplibregl.Map({ container: node, diff --git a/src/components/parking/ParkingViewServices.tsx b/src/components/parking/ParkingViewServices.tsx index 3e4a227..940d6a6 100644 --- a/src/components/parking/ParkingViewServices.tsx +++ b/src/components/parking/ParkingViewServices.tsx @@ -8,7 +8,7 @@ import { } from "~/utils/parkings"; const ParkingViewServices = ({ parkingdata }: { parkingdata: any }) => { - const [allServices, setAllServices ] = React.useState([]); + const [allServices, setAllServices] = React.useState([]); // Set 'allServices' variable in local state React.useEffect(() => { @@ -16,11 +16,11 @@ const ParkingViewServices = ({ parkingdata }: { parkingdata: any }) => { const result = await getAllServices(); setAllServices(result); })(); - },[]) + }, []) const serviceIsActive = (ID: string): boolean => { - for(const x of parkingdata.fietsenstallingen_services) { - if(x.services.ID===ID) { + for (const x of parkingdata.fietsenstallingen_services) { + if (x.services.ID === ID) { return true; } } @@ -28,15 +28,15 @@ const ParkingViewServices = ({ parkingdata }: { parkingdata: any }) => { return false; } - if(parkingdata.fietsenstallingen_services===null||parkingdata.fietsenstallingen_services===undefined) { + if (parkingdata.fietsenstallingen_services === null || parkingdata.fietsenstallingen_services === undefined) { return null } return <> -
+
{allServices && allServices.map(service => { - if(! serviceIsActive(service.ID)) return <> + if (!serviceIsActive(service.ID)) return null; return (
{service.Name}