Local image for marker icon on Cordova/Phonegap Google Maps Plugin

有些话、适合烂在心里 提交于 2020-02-20 09:09:27

问题


Is it possible to use an image locally store on the device as the marker icon? I can use a URL and it works, but when I try to use a local image it won't load. How should I reference the image? This is a multiplatform application so I can't use device specific paths like Android file:///android:asset/

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

I am using Ionic Framework (which uses AngularJS) and Apache Cordova with the Google Maps plugin from https://github.com/wf9a5m75/phonegap-googlemaps-plugin/


回答1:


It doesn't make too much sense but this is what worked:

'icon': 'www/templates/icon2.png'



回答2:


Use a storage plugin, like Cordova Storage, and pull it from there, or a local database. http://docs.phonegap.com/en/1.2.0/phonegap_storage_storage.md.html Capturing and storing a picture taken with the Camera into a local database / PhoneGap / Cordova / iOS



来源:https://stackoverflow.com/questions/26580937/local-image-for-marker-icon-on-cordova-phonegap-google-maps-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!