Currently, you can only access the google.maps reference when you statically reference the Google Maps API (by add the <script src="https://maps.googleapis.com/maps/api/js"></script> to your HTML). However, my application is isomorphic, in order to avoid loading the Google Maps API multiple times, I needed to load it asynchronously- so I opted to loading my API Key via withScriptjs.
Is there a way to access google.maps when loading the Google Maps API asynchronously.
This will be useful for using functions not defined in the package, such as the LatLngBounds method that I am trying to access.
(I need this to try out the solution for centering the map around markers:
https://gist.github.com/dyyylan/a086ed46670efccace96404c8ab97ad8
related to- https://github.com/tomchentw/react-google-maps/issues/260)
The solution that I found was that you can access google.maps through the window:
window.google.maps
All the Google methods can be accessed through this.
I think window.google.maps and google.maps are actually referring to the same thing. They both resolved to the global (window) space. There's no difference using them.
You just need to defer the initialization step after withScriptjs has rendered it's wrapped component.
Most helpful comment
The solution that I found was that you can access google.maps through the window:
window.google.maps
All the Google methods can be accessed through this.