I am Currently working on a website like zillow.com, And I have to show data on the right side of map corresponding to the markers visible on map and whenever the user drags map I have to check for new markers on the map and show on the right panel.
const { isLoaded, loadError } = useJsApiLoader({
googleMapsApiKey: "APIKEY",
libraries: libraries
});
const mapRef = useRef();
const onMapLoad = useCallback((map) => {
mapRef.current = map;
}, [])
return isLoaded && (
<>
<GoogleMap mapContainerStyle={mapContainerStyle}
center={center}
zoom={9.1}
options={options}
onLoad={onMapLoad}
onDragEnd={() => console.log("DRAGGED")}
>
sellerData.map((element, index) => {
return (
<>
<Marker
key={index}
position={
{
lat: element.Marker.lat, lng: element.Marker.lng
}}
icon={{
url: icon,
scaledSize: new window.google.maps.Size(40, 40)
}}
/>
</GoogleMap>
<>
)```