Cannot instantiate google object ( google is undefined )
See original GitHub issueI am using MeteorJS ( 1.4.4 ) + ReactJS, currently i can get the map, markers, working properly. I am using ’ withScriptjs.js ’ async method to render the map, because i tried without the async and it does not work. Here is my problem, i want to use the DirectionsRenderer to draw direction, which is must needed for my traffic jam project, and following the example, I cannot get it works because of google is undefined when the code runs until
const DirectionsService = new google.maps.DirectionsService();
throws the error inside componentDidMount()
.
Because I am still on testing the package, so there is no complex code, and my code was just exactly the same as the example code ( directions ). Thanks you very much for helping.
PS: Awesome package with almost google api completed.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:7 (1 by maintainers)
Solved it by adding:
to the head of my
index.html
, as suggested in the demo project’s source code.@tomchentw This should be documented, willing to send in a pull request.
You can try this after imports :
const google = window.google