I'm working on trying to incorporate an updatable vector layer into my phonegap build with OpenLayers 3. It will check the server for updates and download a new file when necessary.
I can download the file and store it no problem (I use the same code in other apps for non-geojson file types with no problems). I've verified it's existence using the following:
var resortURL = cordova.file.dataDirectory + "resorts.geojson";
window.resolveLocalFileSystemURL(resortURL,function(e){
console.log("located");
},function(e){
console.log("missing");
});
When I go to access the file using OL:
var resortSource = new ol.source.Vector({
url: resortURL,
format: new ol.format.GeoJSON()
});
var resortBoundary = new ol.layer.Vector({
source: resortSource
});
map.addLayer(resortBoundary);
The above fails to add any data to the map, although it does add the layer. I have gone even further and added the geojson file directly to the assets www folder pre-build and accessed it using:
url: "json/resorts.geojson"
Requesting the file from the assets location works exactly as expected. The problem is when I try access it after downloading it to the Data Directory on Android and then trying to access through there. Am I missing something? I've been trying everything under the sun trying to make it work.