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

2

5

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/

Primal answered 27/10, 2014 at 3:49 Comment(7)
icon:'templates/icon2.png' may be this will helpAnders
Thanks but I already tried many different paths :-( This is in the www/js and the icon is in www/templates, that's the reason for the '..', it should be like this, shouldn't it?Primal
just add 'icon': 'icon2.png'Anders
Tried but no luck :-(Primal
Try this link----#24144765Gardel
I think Markers should be added after map is loaded.Gardel
Thanks @prabhu The marker loads fine, it's just the local image that won't load (will show default icon). The link is interesting but doesn't apply because I am not using the the HTML based map, all my map code is in the controller and nothing on the HTML.Primal
P
12

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

'icon': 'www/templates/icon2.png'
Primal answered 27/10, 2014 at 11:4 Comment(2)
Hi momo, thank you for using my plugin. Yes, this is correct answer for this plugin. github.com/wf9a5m75/phonegap-googlemaps-plugin/wiki/…Piggery
Hey, thanks to you for writing the plugin, Katsumata :-) I could use a longer documentation though ;-PPrimal
M
0

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

Marabelle answered 27/10, 2014 at 6:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.