Whenever I use map.fitbound I get a Uncaught TypeError: map.fitBounds is not a function.
The important code snippet:
var bounds = new google.maps.LatLngBounds();
const map = useRef(null);
const getMarkers = (inPins) => {
return inPins.map((pin, pinInd) => {
bounds.extend(pin.position);
map.fitBounds(bounds);
return <Marker {...pin} key={pinInd} />
})
}
return (
<GoogleMap
ref={map}
mapContainerStyle={mapStyles}
defaultZoom={zoom}
center={center}
>
{getMarkers(pins)}
</GoogleMap>
)
I'm not sure what I did wrong. The bounds variable seems to be working fine with the positions, it's just that the map somehow does not have the fitbound function even though google map should should have it and it's been referenced in a lot of tutorials. Any help is appreciated, thank you!