我在我的应用程序中同时使用了 yogiben:autoform-map 和 dburles:google-maps 包。看来他们不能很好地协同工作。使用 dburles:google-maps 的代码工作正常,但自动生成地图抛出此错误:
Exception from Tracker afterFlush function:
TypeError: undefined is not a function
at t.afMap.rendered (d56467d85b9f586916cc49f2dba3c180bfed1ddc.js:210)
at p (d56467d85b9f586916cc49f2dba3c180bfed1ddc.js:154)
at a (d56467d85b9f586916cc49f2dba3c180bfed1ddc.js:154)
at d56467d85b9f586916cc49f2dba3c180bfed1ddc.js:66
at Function.e._withTemplateInstanceFunc (d56467d85b9f586916cc49f2dba3c180bfed1ddc.js:66)
at n (d56467d85b9f586916cc49f2dba3c180bfed1ddc.js:66)
at null.<anonymous> (d56467d85b9f586916cc49f2dba3c180bfed1ddc.js:66)
at d56467d85b9f586916cc49f2dba3c180bfed1ddc.js:65
at Object.c._withCurrentView (d56467d85b9f586916cc49f2dba3c180bfed1ddc.js:65)
at d56467d85b9f586916cc49f2dba3c180bfed1ddc.js:65
我的html:
{{#autoForm class="add" id="add" collection="ServiceProviders" type="insert"}}
{{> afQuickField name="businessname"}}
{{> afQuickField name="officelocation"}}
<button type="submit" class="btn">Create!</button>
{{/autoForm}}
我的收藏:
officelocation: {
type: String,
label: 'Location of Office',
autoform: {
type: 'map',
afFieldInput: {
type: 'map',
geolocation: true,
searchBox: true,
autolocate: true
}
} }
此外,在我添加 dburles:google-maps 包之前,此自动表单运行良好。在 autoform-map.coffee 中调用此代码时,似乎“GoogleMaps”尚未准备好
GoogleMaps.init { libraries: 'places' }, () =>
mapOptions =
zoom: 0
mapTypeId: google.maps.MapTypeId[@data.options.mapType]
streetViewControl: false
这看起来很奇怪,因为我已经在做流星启动:
Meteor.startup(function() {
if (GoogleMaps.loaded()?false:true) {
GoogleMaps.load();
}
});