【问题标题】:phonegap-googlemaps-plugin in ionic, icon image not working离子中的phonegap-googlemaps-plugin,图标图像不起作用
【发布时间】:2015-11-08 00:35:02
【问题描述】:

是否可以使用本地存储在设备上的图像作为标记图标?我可以使用 URL 并且它可以工作,但是当我尝试使用本地图像时它不会加载。我应该如何引用图像?

map.addMarker({
    'position': new plugin.google.maps.LatLng(13.7579507,100.5643353),
    'title': 'Fortune Town',
    'icon': 'img/icon.png'
}, function(marker) {
    marker.showInfoWindow();
});

将 Ionic Framework 和 Cordova 与来自 https://github.com/wf9a5m75/phonegap-googlemaps-plugin/ 的 Google 地图插件结合使用

已经提到 Local image for marker icon on Cordova/Phonegap Google Maps Plugin 并尝试了icon:"www/img/icon.png",但这不起作用。

【问题讨论】:

  • 显然没有同样的问题,我不得不将我的图像存储在服务器上并占用它,然后我就跑了。

标签: ionic-framework


【解决方案1】:

编辑:抱歉,刚刚注意到该插件使用的 api 与 Google maps web 版本的 JS API 不同。因此这个答案是无效的。我们在 ionic 中成功使用了 JS 网页版的谷歌地图,代码如下。


我们使用它,它在我们测试的所有设备以及浏览器中的ionic serve 中都能很好地工作。

/www/imageswww 的子文件夹

 new google.maps.Marker({
      position: thisPos,
      map: $scope.map,
      title: myRequest.title,
      icon: {
          url: 'images/scaled30-' + myRequest.category + '.png',
          size: new google.maps.Size(34, 63),
          scaledSize: new google.maps.Size(34, 63),
          origin: new google.maps.Point(0, 0),
           // The anchor for this image is the base of the tip at 18,63.
           anchor: new google.maps.Size(17, 63)
      },

      request: myRequest
});

【讨论】:

    【解决方案2】:

    插件是为cordova4编写的,当使用cordova5运行时,privateInitialize方法没有被正确调用

    Cosmith 的某个人已经解决了这个问题

    参考链接:

    https://github.com/wf9a5m75/phonegap-googlemaps-plugin/issues/537

    https://github.com/cosmith/phonegap-googlemaps-plugin#bugfix/icon-crash-cordova-5 --variable API_KEY_FOR_ANDROID="API_KEY" --variable API_KEY_FOR_IOS="API_KEY"

    ^无论如何感谢大家的帮助

    【讨论】:

      猜你喜欢
      • 2015-12-08
      • 1970-01-01
      • 2019-02-11
      • 1970-01-01
      • 2014-12-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多