Google maps 在meteor项目中加载Google地图
我有一个让我的流星计划显示地图的问题。我使用dburles作为我的googleapi库。我已经按照教程中的说明进行了操作,我的GoogleMaps.load()返回undefined,这就是我认为根本的问题所在Google maps 在meteor项目中加载Google地图,google-maps,meteor,coffeescript,pug,meteor-accounts,Google Maps,Meteor,Coffeescript,Pug,Meteor Accounts,我有一个让我的流星计划显示地图的问题。我使用dburles作为我的googleapi库。我已经按照教程中的说明进行了操作,我的GoogleMaps.load()返回undefined,这就是我认为根本的问题所在 Meteor.startup -> GoogleMaps.load() console.log GoogleMaps.load() return 我的玉看起来像这样 div#search-wrapper
Meteor.startup ->
GoogleMaps.load()
console.log GoogleMaps.load()
return
我的玉看起来像这样
div#search-wrapper
h2 Search for a ATM
div#search-input.input-group
input(for="search" type="text" placeholder="City, State, Zip, ect")
div.input-group-append
button(type="submit" class="btn btn-info " id="search-button")
i.fas.fa-search
button(type="submit" class="btn btn-info" id="find-nearMe") Find Near Me
+map
template(name="map")
div.map-container
googleMap(name="map" options=mapOptions)
我知道coffeescript和jade没有被广泛使用,所以Javascript的答案也可以接受。该库最近没有更新。它来自一个时代,当NPM是一个黑客在流星 您可以尝试根据自己的喜好修改此ES6代码(使用自己的google密钥)。在实际需要地图的屏幕加载时调用此函数。当函数检查映射是否存在时,可以从多个页面多次调用它。除非您在第一个屏幕上显示地图,否则您不希望在启动时使用此功能,但再次调用组件/视图级别的函数
const loadGoogleMaps=()=>{
如果(!window.google?.maps){
常量脚本=document.createElement('script')
script.src=https://maps.googleapis.com/maps/api/js?key=xxxxxx&libraries=places'
script.defer=true
document.head.appendChild(脚本)
}
}
导出{loadGoogleMaps}
另一种选择是使用官方NPM()。请提供您正在使用的库和教程的链接。