tomchentw / react-google-maps

React.js Google Maps integration component
https://tomchentw.github.io/react-google-maps/
MIT License
4.62k stars 938 forks source link

How to use fitBounds, panTo, etc #62

Closed mikefowler closed 9 years ago

mikefowler commented 9 years ago

Could you provide some more documentation on how to use these <GoogleMaps /> helper methods?

dmitry commented 9 years ago

You can access them directly through refs, as it's shown here: https://github.com/tomchentw/react-google-maps/issues/17

tomchentw commented 9 years ago

I took a day to rewrite the module from scratch on #88 . However, I remove these method from the component APIs. Do you guys think it's a good idea to remove it or keep it?

LarryEitel commented 9 years ago

I have a use case for using fitBounds. Do you expose the google map object so that it would be possible to act directly on it? Or is that philosophically improper?

tomchentw commented 9 years ago

It's not a easy design decision and I certainly believe exposing it is philosophically improper. But I cannot come up with a better way other than exposing getter though ...

LarryEitel commented 9 years ago

I would be in favor of exposing it recognizing that even though it may be improper it may be the only way to achieve something that would otherwise require scrapping the use of the project altogether. :)

tomchentw commented 9 years ago

Released v2.0.0 and v2.0.1.

outdooricon commented 9 years ago

Now with the rewrite, I'm pretty confused on what the correct way to use these is... especially fitBounds. I assume that panBounds is useless to set since I assume a new map is created every time state changes (is that right?). But setting fitBounds doesn't seem to actually work. Could you give us an example of how we should be setting the bounds? Thanks for this great project!

tomchentw commented 9 years ago

State changes will only be applied when you have controlled properties. Try calling fitBounds in your cDU?

outdooricon commented 9 years ago

isn't fitbounds a controlled property?

tomchentw commented 9 years ago

@outdooricon it's public APIs from the ref: http://git.io/vGc4H

outdooricon commented 9 years ago

Ok, I think i understand. I'm really curious what the use case of even exposing the these other properties that @LarryEitel has. It's pretty confusing to expose these if they don't really work.