Reputation: 6027
I am using google-map-react
and need to have access to the map
.
I access the ref through doing something like:
<GoogleMap ref={ref => this.map = ref} />
When I call the ref on componentDidMount()
like so this.map.map_
it returns null because the map has not loaded yet. I need a way to access this when the component mounts.
Upvotes: 0
Views: 2147
Reputation: 36219
I think you can use onGoogleApiLoaded:
handleGoogleApiLoaded = ({map, maps}) => {
map...
}
<GoogleMap
onGoogleApiLoaded={this.handleGoogleApiLoaded}
yesIWantToUseGoogleMapApiInternals
/>
Upvotes: 1