-
Hello everyone, I need to access a function called I'm providing this minimum example to show you guys the problem I'm facing. https://codesandbox.io/s/kind-jackson-i3z1r?file=/src/App.tsx Am I doing something wrong ? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Sorry guys. It was a dumb question. The bounds are not settled yet when I'm trying to accessing it from my component. I'll check this and provide a sample for future readers. Thank you all. |
Beta Was this translation helpful? Give feedback.
-
Hello guys, /* global google */
export default function App() {
const mapRef = useRef<google.maps.Map>();
const onLoad = (map: any) => {
mapRef.current = map;
};
const onBoundsChanged = () => {
if (mapRef.current) {
const bounds = mapRef.current.getBounds();
console.log('onBoundsChange', bounds);
}
};
return (
<LoadScript
googleMapsApiKey={API_KEY}
>
<GoogleMap
onLoad={onLoad}
onBoundsChanged={onBoundsChanged}
center={center}
zoom={12}
mapContainerStyle={containerStyle}
>
<></>
</GoogleMap>
</LoadScript>
);
} |
Beta Was this translation helpful? Give feedback.
Hello guys,
As I said, this was a mistake I made using React, it's not related to this library. I solved it with this code: