// eslint-disable-next-line import React, { useState, useEffect, Component } from "react"; import { GoogleMap, useLoadScript, Marker, InfoWindow, } from "@react-google-maps/api"; import usePlacesAutocomplete, { getGeocode, getLatLng, } from "use-places-autocomplete"; import { Combobox, ComboboxInput, ComboboxPopover, ComboboxList, ComboboxOption, } from "@reach/combobox"; import { formatRelative } from "date-fns"; import Select from "react-select"; import "@reach/combobox/styles.css"; import mapStyles from "./mapStyles"; import * as listingData from "./data/property-data.json"; import "./ListingsPage.css"; import compassImg from "./compass.svg"; const libraries = ["places"]; const mapContainerStyle = { height: "700px", width: "100vm", }; const options = { styles: mapStyles, disableDefaultUI: true, zoomControl: true, }; const center = { lat: 45.4231, lng: -75.6931, }; export default function ListingsPage() { const price_filter = [ { value: null, label: "Any", }, { value: 100000, label: "$100000", }, { value: 200000, label: "$200000", }, { value: 300000, label: "$300000", }, { value: 400000, label: "$400000", } ]; const bed_filter = [ { value: null, label: "Any", }, { value: 1, label: "One Bed", }, { value: 2, label: "Two Beds", }, { value: 3, label: "Three Beds", } ]; const bath_filter = [ { value: null, label: "Any", }, { value: 1, label: "One Bath", }, { value: 2, label: "Two Baths", }, { value: 3, label: "Three Baths", } ]; //console.log(data1[0]); const { isLoaded, loadError } = useLoadScript({ googleMapsApiKey: `https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=geometry,drawing,places&key= AIzaSyC5TiZoTEwEcB_HUZRhe_rXrcSWW1Z5x8I`, libraries, }); const [selectedBudget, setSelectedBudget] = useState(null); const [selectedBeds, setSelectedBeds] = useState(null); const [selectedBaths, setSelectedBaths] = useState(null); const [markers, setMarkers] = React.useState([]); const [selected, setSelected] = React.useState(null); const [budget, setBudget] = useState(null); const [bed, setBed] = useState(null); const [bath, setBath] = useState(null); const mapRef = React.useRef(); const onMapLoad = React.useCallback((map) => { mapRef.current = map; //console.log(current); }, []); const panTo = React.useCallback(({ lat, lng }) => { mapRef.current.panTo({ lat, lng }); mapRef.current.setZoom(10); }, []); if (loadError) return "Error"; if (!isLoaded) return "Loading..."; // handle onChange event of the dropdown const handleBudgetChange = (e) => { setSelectedBudget(e); setBudget(e.value); //https://stackoverflow.com/questions/54150783/react-hooks-usestate-with-object //https://stackoverflow.com/questions/57341541/removing-object-from-array-using-hooks-usestate/57341724 }; const handleBedChange = (e) => { setSelectedBeds(e); setBed(e.value); }; const handleBathChange = (e) => { setSelectedBaths(e); setBath(e.value); }; return (