Lets say I have /public/images/marker.png. Whats the best way to get the cordova local file path so I can hand it to the native google maps plugin for cordova. (For instance, for a marker icon)
This StackOverflow question is asking basically the same thing.
cordova, meteor
This finally worked for me.
getLocalPath = function(file) {
return cordova.file.applicationDirectory.replace(‘file://’, ‘’) + ‘www/application/’ + file;
};
getLocalPath(‘bell.wav’)
I have tried that… also ‘www/application’ + file, and ‘www/’ + path, but nothing has worked You were able to get the marker icon to show on the map?
what finally worked for me was
'www/application/app' + file
Yep that is the correct path now.
When I posted 3 months ago Cordova still hadn’t been upgraded and so it was a different path. Glad you figured it out!
marc2
January 22, 2016, 11:07am
7
Is this still working? I got some sound file in my public directory like ‘public/sounds/test.mp3’. I tried to access the file via
var sound = new Sound('www/application/app/sounds/test.mp3');
but the sound couldn’t be loaded. Anyone an idea?
marc2
January 22, 2016, 11:32am
8
I read about that issue here https://github.com/meteor/guide/issues/40
cordova.file.applicationDirectory + 'www/application/app/' + yourFilePath
gives me
file:///android_asset/www/application/app//sounds/test.mp3
which sees to be the correct path.