react-googlemaps
react-googlemaps copied to clipboard
Cannot call getMapNode()
When created a map component like this:
var ReactGoogleMaps = require('react-googlemaps');
var Map = ReactGoogleMaps.Map;
<Map
ref="myMap"
initialZoom={15}
initialCenter={new google.maps.LatLng(53.4335187, 14.5497363)}
</Map>
In the parent component, that created it, I would like to do this.refs.myMap.getMapNode(). However this is not possible, because the ReactGoogleMaps.Map is not exposing such method.
My motivation is to centre the map after the component is rendered, in componentDidMount. I want to do it using map.panTo method of Google API.
I had the same problem, try this: this.refs.myMap.refs.map.getMapNode().
Thanks for a tip.
Is that really the best way to get the map instance? It seems so brittle :confused:
any status on this? would be nice to know best practice regarding getMapNode().