dburles / meteor-google-maps

🗺 Meteor package for the Google Maps Javascript API v3
https://atmospherejs.com/dburles/google-maps
MIT License
196 stars 48 forks source link

google is not defined #121

Closed aditzend closed 7 years ago

aditzend commented 8 years ago

Hi !

I am using this package together with jeremy:geocomplete version 1.7.0

I am getting this error on a Meteor 1.3 app:

Exception from Tracker afterFlush function: debug.js:41 ReferenceError: google is not defined at GeoComplete.initGeocoder (jquery.geocomplete.js:191) at GeoComplete.init (jquery.geocomplete.js:107) at new GeoComplete (jquery.geocomplete.js:99) at HTMLInputElement. (jquery.geocomplete.js:586) at Function.each (jquery.js:384) at jQuery.each (jquery.js:136) at jQuery.$.fn.geocomplete (jquery.geocomplete.js:582) at . (Place_create.js:57) at view.js:199 at Function.Template._withTemplateInstanceFunc (template.js:465)

GoogleMaps is loaded on startup and that does not bring any errors. This happens when the template is rendered.

Any help is very much appreciated!!!!

dburles commented 8 years ago

You need to make sure that any references to google are after GoogleMaps.loaded() is true

aditzend commented 8 years ago

Thanks a lot for your reply and your great package! There was a problem with my key.

fvpDev commented 7 years ago

So I checked/created a new API key but when I have the following I get false in console:

import { Meteor } from 'meteor/meteor';
import { GoogleMaps } from 'meteor/dburles:google-maps';

Meteor.startup(() => {
  GoogleMaps.load({
    key: 'my-key-that-is-secret',
    libraries: 'geometry,places'
  });
  console.log(GoogleMaps.loaded());
});
dburles commented 7 years ago

@fvpDev 1. you don't need to import GoogleMaps. 2. GoogleMaps.loaded() is a reactive function (you need to reference it within an autorun)