Meteor GoogleMaps.load()在使用Iron的iOS上无效

时间:2015-10-23 19:25:50

标签: ios node.js cordova meteor iron

我正在尝试使用Meteor在页面上加载带标记的简单地图。我正在使用GoogleMaps packageIron

地图在我的浏览器中正确显示但是当我尝试使用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

我不确定这是一个人为的错误还是一个问题,但是我已经好几个小时了,而且我真的没有得到它

注意:在我的测试回购中,我在iOS上点击一些alert()来清楚地看到问题。

对这个问题有什么想法吗?抱歉,CoffeeScript和Iron结构。

1 个答案:

答案 0 :(得分:2)

在Cordova上使用外部API时,您需要在项目目录的顶层配置mobile-config.js文件。

对于google api,你的mobile-config.js看起来像

App.accessRule('*.googleapis.com/*');

docs