Meteor GoogleMaps.load() 无法使用 Iron 在 iOS 上工作
Meteor GoogleMaps.load() not working on iOS with Iron
我正在尝试使用 Meteor 在页面上加载带有标记的简单地图。我正在使用 GoogleMaps package and Iron.
地图在我的浏览器中正确显示,但当我使用 iOS 模拟器 (iPhone 6 / iOS 8.3) 尝试时,它只是从未加载:它是自动的运行,系统返回 false
GoogleMaps.loaded()
...
另一边,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 结构。
在 Cordova 上使用外部 API 时,您需要在项目目录的顶层配置一个 mobile-config.js 文件。
对于 google api,您的手机 config.js 看起来像
App.accessRule('*.googleapis.com/*');
我正在尝试使用 Meteor 在页面上加载带有标记的简单地图。我正在使用 GoogleMaps package and Iron.
地图在我的浏览器中正确显示,但当我使用 iOS 模拟器 (iPhone 6 / iOS 8.3) 尝试时,它只是从未加载:它是自动的运行,系统返回 false
GoogleMaps.loaded()
...
另一边,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 结构。
在 Cordova 上使用外部 API 时,您需要在项目目录的顶层配置一个 mobile-config.js 文件。
对于 google api,您的手机 config.js 看起来像
App.accessRule('*.googleapis.com/*');