2016-02-29 36 views
0

我已經安裝了lukemadera:autoform-googleplace包,並遵循了使用說明。當我運行應用程序時,地址字段不會在我輸入時自動填充。我在控制檯中遇到錯誤(Exception in template helper: ReferenceError: EJSON is not defined)有人可以告訴我我錯過了什麼。meteor - autoform-googleplace

路徑:Layout.html

<head> 
    <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?libraries=places"></script> 
</head> 

路徑:Schema.js

Schema.Address = new SimpleSchema({ 
    fullAddress: { 
     type: String 
    }, 
    lat: { 
     type: Number, 
     decimal: true 
    }, 
    lng: { 
     type: Number, 
     decimal: true 
    }, 
    geometry: { 
     type: Object, 
     blackbox: true 
    }, 
    placeId: { 
     type: String 
    }, 
    street: { 
     type: String, 
     max: 100 
    }, 
    city: { 
     type: String, 
     max: 50 
    }, 
    state: { 
     type: String, 
     regEx: /^A[LKSZRAEP]|C[AOT]|D[EC]|F[LM]|G[AU]|HI|I[ADLN]|K[SY]|LA|M[ADEHINOPST]|N[CDEHJMVY]|O[HKR]|P[ARW]|RI|S[CD]|T[NX]|UT|V[AIT]|W[AIVY]$/ 
    }, 
    zip: { 
     type: String, 
     regEx: /^[0-9]{5}$/ 
    }, 
    country: { 
     type: String 
    } 
}); 

Schema.UserProfile = new SimpleSchema({ 
    address: { 
     type: Schema.Address, 
     optional: true 
    } 
}); 

路徑:personalDetails.js

<template name="personalDetails"> 
{{#autoForm collection="Meteor.users" id="candidateProfile" doc=currentUser type="update"}} 

    {{> afQuickField name="profile.address" type="googleplace" opts=optsGoogleplace}} 

{{/autoForm}} 
</template> 

路徑:personalDetails.js

Template.personalDetails.helpers({ 
    optsGoogleplace: function() { 
    return { 
     // type: 'googleUI', 
     // stopTimeoutOnKeyup: false, 
     // googleOptions: { 
     // componentRestrictions: { country:'us' } 
     // } 
    } 
    } 
}); 
+0

您是否嘗試將'EJSON is not defined'放入谷歌中以查看發生了什麼? –

+0

是的,但我找不到任何東西。在說明中沒有提到有關設置json文件的任何信息。這可能是問題嗎? – bp123

+0

noo。這是因爲你錯過了一個包。從我的地方的第一個谷歌結果立即顯示解決方案 –

回答

0

僅供參考,以防萬一別人得到此錯誤,您需要安裝ejson