是否可以使用本地存储在设备上的图像作为标记图标?我可以使用URL并且它可以工作,但是当我尝试使用本 Map 像时它将无法加载 . 我应该如何参考图像?
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 Maps插件
已经提到Local image for marker icon on Cordova/Phonegap Google Maps Plugin并尝试 icon:"www/img/icon.png"
,但这不起作用 .
2 回答
编辑:对不起,只是注意到插件使用的不同于谷歌 Map 网络版的JS API . 因此,这个答案是无效的 . 我们通过下面的代码成功地使用JS Web版Google Map .
我们使用它,它在我们测试的所有设备中以及在浏览器中使用
ionic serve
时都能很好地工作 ./www/images
是www
的子目录插件是为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 - 变量API_KEY_FOR_ANDROID = "API_KEY" - 变量API_KEY_FOR_IOS = "API_KEY"
^无论如何,谢谢你的帮助