Open s-pic opened 8 years ago
Hi! Assuming there are no other issues, it should work without you needing to touch the sqlite plugin. Suppose your sqlite database is "testme.mbtiles" and in the "www" folder. Then in the example you just need to use "testme" as the source name in the map style. See using "naturalearth" here: https://github.com/trevorpowell/mapbox-gl-js-cordova-offline-example/blob/master/www/index.html#L34 https://github.com/trevorpowell/mapbox-gl-js-cordova-offline-example/blob/master/www/index.html#L54
Hi Trevor,
thanks for your answer. In my case, "testme.mbtiles" cannot reside in the www folder, it has to be downloaded via cordova-plugin-file-transfer, otherwise the the .apk gets to big. Opening the downloaded mbtiles file is working like a charm, when it's raster tiles and leaflet. I would really like to use a vector tiles mbtiles-file, to reduce file size and because it is cooler. ;)
So I kind of have to change the part in mapbox-gl-js, where the db gets opened: https://github.com/trevorpowell/mapbox-gl-js-cordova-offline-example/blob/master/www/mapbox-gl.js#L72
Maybe I cann pass my db object (Result of window.sqlitePlugin.openDatabase) to the constructor of map, maybe there is a simpler approach.
Since I am still a beginner, I hoped you have already encountered that problem and that you could give a hint.
Anyways, thanks.
Hello @trevorpowell,
I am playing around with offline maps because I am writing my thesis about that topic, and am very happy that I found your work, good stuff. I am still a beginner in development, so I am hoping to solve my problem with this question:
Assuming I have already opened the db in my sandboxed file system in my main.js via
// Opens the downloaded DB via sqlite plugin at file:////data/user/0/{packageName}/databases, function openDB() { db = window.sqlitePlugin.openDatabase({ location: 'default', name: localFileName, androidDatabaseImplementation: 2, // since reading blobs androidLockWorkaround: 1 }); }
How can I make mapbox-gl.js use this db? I can't figure quite figure out what is happening in the code.