FOSS4G 2013 - Presentation by Pierre GIRAUD
github.com/pgiraud / @pgira
Usually limited to 5MB.
~400 tiles
-> Doesn't suit the needs.
Result: File better than Database
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0,
function(fs) {
fs.root.getDirectory(
"newDir",
{create: true, exclusive: false},
function(dirEntry) {
// do something with dirEntry.fullPath
},
onDirError
},
onFsError
);
var fileTransfer = new FileTransfer();
fileTransfer.download(
url,
path + '/' + fileName,
function(file) {
// file successfully downloaded
// update percent done counter
},
onError
);
+ | + | = |
var SavedMapLayer = OpenLayers.Class(OpenLayers.Layer.XYZ, {
async: true, // because Cordova File API is asynchronous
fs: null, // the FileSystem
uuid: null, // id of the layer to build filenames
...
getURLasync: function(bounds, callback, scope) {
...
this.fs.root.getFile(
path + '/' + fileName,
null,
function(fileEntry) {
callback.call(scope, fileEntry.toURL());
},
onError
);
}
});
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fs) {
[...]
var layer = new SavedMapLayer(
'savedmap',
{
isBaseLayer: true,
fs: fs,
uuid: uuid,
[...]
}
);
[...]
});