meteor-autoform-map
meteor-autoform-map copied to clipboard
SearchBox undefined
I am getting this error:
Exception from Tracker afterFlush function: debug.js:41 TypeError: Cannot read property 'SearchBox' of undefined at initTemplateAndGoogleMaps (autoform-map.coffee:82) at null.<anonymous> (autoform-map.coffee:112) at view.js:199 at Function.Template._withTemplateInstanceFunc (template.js:457) at view.js:197 at Object.Blaze._withCurrentView (view.js:538) at viewAutorun (view.js:196) at Tracker.Computation._compute (tracker.js:323) at new Tracker.Computation (tracker.js:211) at Object.Tracker.autorun (tracker.js:562)
The map displays fine, but the search box does not appear.
However if I reload the page that contains this template then there is no problem. So the problem only appears when I get to the page from another page on the own site.
Situatution:
I am using dburles:googl-maps
so display different maps on my app.
I am also using yogiben:autoform-map
to let user input their location in a form.
Problem:
I was calling GoogleMaps.load()
every time a map template was rendered with onRendered
. Somehow this was preventing the GoogleMaps.load({libraries:'places'})
inside yogiben:autoform-map
to load the library properly.
Solution:
I removed the GoogleMaps.load()
from the map templates and placed it in:
Meteor.startup(function() {
GoogleMaps.load({
libraries: 'places'
});
});
This way I ensure that the libraries that I need are included.
Can anyone think of a better solution?
+1