【发布时间】:2016-01-23 10:36:53
【问题描述】:
我正在尝试使用 Meteor 在页面上加载带有标记的简单地图。我正在使用GoogleMaps package 和Iron。
地图在我的浏览器中正确显示,但是当我使用 iOS 模拟器(iPhone 6 / iOS 8.3)尝试它时,它永远不会加载:它是自动运行的,在 GoogleMaps.loaded() 上系统地返回 false ...
另一方面,Geolocation 正在正确返回一个位置。
这是我设置的用于查看整个问题的存储库:https://github.com/Loschcode/meteor-iron-google-maps-issue
重要的几行可能是GoogleMaps 包设置:
#
# Helpers
#
Template.GeoMap.helpers {
geolocationError: =>
error = Geolocation.error()
return error and error.message
mapOptions: =>
latLng = Geolocation.latLng()
if (Meteor.isCordova)
alert(GoogleMaps.loaded())
# Initialize the map once we have the latLng.
if GoogleMaps.loaded() and latLng
if (Meteor.isCordova)
alert('GoogleMaps.loaded')
return {
center: new google.maps.LatLng(latLng.lat, latLng.lng)
zoom: @MAP_ZOOM
}
}
以及过程:
#
# onCreated
#
Template.GeoMap.onCreated =>
GoogleMaps.load()
if (Meteor.isCordova)
alert('GoogleMaps.load')
# When it's ready, we process the position
GoogleMaps.ready 'geoMap', (map) =>
# THIS IS NEVER FIRED
我不确定这是人为错误还是问题,但我已经做了好几个小时了,我真的不明白
注意:在我的测试存储库中,我让一些 alert() 在 iOS 上触发以清楚地看到问题。
对这个问题有任何想法吗?对不起 CoffeeScript 和 Iron 结构。
【问题讨论】:
-
您可能需要将 Googlemaps.ready 代码放入 OnRendered 中,尤其是在您引用 DOM 时
-
抱歉阅读速度太快,没有意识到问题 wasonCordova。您是否设置了带有 Google Api 访问规则的 mobile-config.js?
-
天哪,你是对的蓝鸟,把它写成答案,我会接受的!我太愚蠢了,我忘了设置
mobile-config.js
标签: ios node.js cordova meteor iron