Closed XBLDev closed 5 years ago
Hey, you should be able to just use the GoogleMaps.loaded()
method within your helper.
@dburles Hi thx for your reply, but I'm experiencing this weird situation where even if GoogleMaps.loaded() returns true, the autocomplete simply doesn't work, when I check google.maps.places is always returns null.
However if I just somehow refresh the page, say in onRendered function, check if google.maps.places exists and if not do location.reload, and when the page is reloaded the places library is there/autocomplete works properly. I'm using it on one of my pages as a temporary fix for this problem, don't know how this is even possible.
Strange, are you able to create a simple isolated reproduction?
@dburles hi i'm afraid i don't have a simple isolated reproduction atm, I'll keep looking for solutions , and will my answer here if I find any. I guess this one can be closed for now, thank you!
I need the places library to do the autocomplete, and I load google map like this: GoogleMaps.load({ key: 'mykey', libraries: 'places'});
And I need a way to check if the library is loaded, because sometimes it gives errors such as "google.maps.places" undefined.
What's the best way to do this with meteor template? I find that if you put the checking in a helper function it gets stuck forever, something like:
gmaploaded: function(){ return google.maps.places!=null; }
Which I think is probably wrong at so many levels.
Thanks in advance for any answer!
Edit:
One weird thing: if I make a random change to my code, say just add a line of comment, which is completely irrelevant, and save let it hot reload, places library loads and autocomplete works, don't know why.