Matt-Jensen / ember-cli-g-maps

Deprecated Google Maps Addon
http://matt-jensen.github.io/ember-cli-g-maps
MIT License
59 stars 31 forks source link

Google is not defined with Fastboot #89

Closed HarryLafranc closed 7 years ago

HarryLafranc commented 7 years ago

Hi,

I try to install FastBoot on my existing Ember project. I already use ember-cli-g-maps without Fastboot and it works well, but as soon as I install it I have this error "ReferenceError: google is not defined".

I'm using the google var for markers (google.maps.Size, google.maps.Point) like this :

let icon = { url: '/assets/img/search_marker.png', size: new google.maps.Size(10, 10), origin: new google.maps.Point(0, 0), anchor: new google.maps.Point(5, 5), };

I use the PlacesService too (google.maps.places.PlacesService).

I know Google Map must be depending a lot on the DOM, but how can I still have my custom markers and places service with FastBoot ? Am I missing something ?

Thanks !

Matt-Jensen commented 7 years ago

Hey Harry, are you using lazy loading? If so we should rule out any race conditions that would prevent the google global from being available. Internally this addon uses this function https://github.com/Matt-Jensen/ember-cli-g-maps/blob/master/addon/utils/load-google-maps.js#L33 to ensure that google is available.

HarryLafranc commented 7 years ago

Hey Matt, thanks for your reply !

I don't think I'm using lazy loading, at least I didn't activated anything to have lazy loading. Is it built in Ember ? Is it better to use lazy loading with Fastboot ?

Matt-Jensen commented 7 years ago

The lazy loading of the google dependencies is written in Ember. Nothing lazily loaded by default, so odds are you are not using it.

Is it better to use lazy loading with Fastboot?

Isn't going to help us.

Since I don't have any of your code to debug, I can only assume the code where you're creating Google Points and Size instances is getting run before google has a chance to load. Unless you want to give me an example repo of the issue you could either:

A) Wrap your above code to prevent it from running in Fastboot. B) Wrap your above code with the google maps promise I linked to earlier.

I don't know if either of those will work, but we can't definitively say there is an issue with this addons' code as the error seems to be originating from your code.

However I welcome you to prove me wrong there. 👆