2016-06-14 49 views
0

我想把我的谷歌地圖初始化工作代碼放入流星項目中,並得到兩個錯誤,分別是Unexpected token <initMap is not a function。我給出的HTML文件的代碼如下:google maps api 3:如何解決「意外令牌」的錯誤?

<head> 
    <title>simple</title> 
</head> 

<body> 
    <h1>Welcome to Meteor!</h1> 

    {{> hello}} 
    {{> info}} 
    <script src="main.js"></script> 
    <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBNRzOGCsGk5u0VHjDOh_4QyJf4K-Hz5Bw&signed_in=true&libraries=places&callback=initMap" 
    async defer></script> 
</body> 

<template name="hello"> 
    <button>Click Me</button> 
    <p>You've pressed the button {{counter}} times.</p> 
</template> 

<template name="info"> 
    <h2>Learn Meteor!</h2> 
    <ul> 
    <li><a href="https://www.meteor.com/try">Do the Tutorial</a></li> 
    <li><a href="http://guide.meteor.com">Follow the Guide</a></li> 
    <li><a href="https://docs.meteor.com">Read the Docs</a></li> 
    <li><a href="https://forums.meteor.com">Discussions</a></li> 
    </ul> 
</template> 
+0

'Unexpected token <'where?哪一行文件?它在'main.js中嗎?'調試器應該告訴你 –

回答

1

使用此包。

您不需要添加main.js,流星會照顧到這一點。

你也可以看到這個樣本example

0

你不能像在流星應用中那樣添加google maps api。有一個封裝,這將有助於你從地圖atmospherejs dburles:google-maps

的文檔很好的解釋集成到應用程序

dburles:google-maps