Function apiIsLoaded doesn't get called, and map can't be initialized. What's wrong? When inspecting, I can see a div without a google map iframe, just empty space. I need to apiIsLoaded be called, but cant find any way to do this. Here is the code, any help would be appreciated.
import React from 'react';
import GoogleMapReact from "google-map-react";
const LocationMap = (props) => {
const apiIsLoaded = (map, maps) => {
if (map) {
map.setOptions({ gestureHandling: 'greedy', mapTypeControl: false, minZoom: 2});
}
};
const { address } = props;
const center = address ? { lat: address.lat, lng: address.lon } : { lat: 0, lng: 0 };
return (
<div className="google-maps-wrapper">
<GoogleMapReact
bootstrapURLKeys={{
key: process.env.REACT_APP_MAP_KEY
}}
defaultZoom={address ? 8 : 2}
center={[center.lat, center.lng]}
defaultCenter={[0, 0]}
yesIWantToUseGoogleMapApiInternals={true}
onGoogleApiLoaded={({ map, maps }) => apiIsLoaded(map, maps)}>
</GoogleMapReact>
</div>
);
};
export default LocationMap;