Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot call getMapNode() #9

Open
lpiepiora opened this issue Nov 2, 2014 · 4 comments
Open

Cannot call getMapNode() #9

lpiepiora opened this issue Nov 2, 2014 · 4 comments

Comments

@lpiepiora
Copy link

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.

@MicheleBertoli
Copy link

I had the same problem, try this: this.refs.myMap.refs.map.getMapNode().

@lpiepiora
Copy link
Author

Thanks for a tip.

@aaronpowell
Copy link

Is that really the best way to get the map instance? It seems so brittle 😕

@davidlashlee
Copy link

any status on this? would be nice to know best practice regarding getMapNode().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants