GithubHelp home page GithubHelp logo

trevorpowell / mapbox-gl-js-cordova-offline-example Goto Github PK

View Code? Open in Web Editor NEW
18.0 18.0 7.0 3.81 MB

Example Cordova project using https://github.com/trevorpowell/mapbox-gl-js-cordova-offline

HTML 16.33% CSS 83.67%

mapbox-gl-js-cordova-offline-example's People

Contributors

trevorpowell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

mapbox-gl-js-cordova-offline-example's Issues

combining online and offline maps?

Hi,

Would it be possible to combine online and offline sources. I currently have the library running using offline sources as described in the documentation, but when I try to add an online map box source, I can't get it to work. If this is possible, how would you go about it?

best,
Richard

App crashes on startup

Hi, just wanted to try your great example app.
The app crashes with the logcat output as pasted below. The error "JNI DETECTED ERROR IN APPLICATION: input is not valid Modified UTF-8: illegal start byte 0x8b" seems to be thrown when execting the query "SELECT tile_data FROM tiles WHERE zoom_level = ? AND tile_column = ? AND tile_row = ?".

I/chromium(17723): [INFO:CONSOLE(174)] "OPEN database: naturalearth.mbtiles", source: file:///android_asset/www/plugins/io.litehelpers.cordova.sqlite/www/SQLitePlugin.js (174)
V/SQLitePlugin(17723): Android db implementation: sqlite4java (NDK)
I/chromium(17723): [INFO:CONSOLE(105)] "new transaction is waiting for open operation", source: file:///android_asset/www/plugins/io.litehelpers.cordova.sqlite/www/SQLitePlugin.js (105)
V/info    (17723): Open sqlite db: /data/data/com.example.offlinemap/databases/naturalearth.mbtiles
V/sqlg    (17723): db_open /data/data/com.example.offlinemap/databases/naturalearth.mbtiles 6
V/sqlg    (17723): db_open /data/data/com.example.offlinemap/databases/naturalearth.mbtiles result 0 ptr 0xb8db4758
I/chromium(17723): [INFO:CONSOLE(105)] "new transaction is waiting for open operation", source: file:///android_asset/www/plugins/io.litehelpers.cordova.sqlite/www/SQLitePlugin.js (105)
I/chromium(17723): [INFO:CONSOLE(105)] "new transaction is waiting for open operation", source: file:///android_asset/www/plugins/io.litehelpers.cordova.sqlite/www/SQLitePlugin.js (105)
I/chromium(17723): [INFO:CONSOLE(105)] "new transaction is waiting for open operation", source: file:///android_asset/www/plugins/io.litehelpers.cordova.sqlite/www/SQLitePlugin.js (105)
I/chromium(17723): [INFO:CONSOLE(79)] "DB opened: naturalearth.mbtiles", source: file:///android_asset/www/plugins/io.litehelpers.cordova.sqlite/www/SQLitePlugin.js (79)
D/audio_hw_primary(  243): out_standby: enter: stream (0xb79dc938) usecase(1: low-latency-playback)
V/sqlg    (17723): prepare db 0xb8db4758 sql BEGIN
V/sqlg    (17723): sqlc_st_finish 0xb8dcf8e8
V/sqlg    (17723): prepare db 0xb8db4758 sql SELECT tile_data FROM tiles WHERE zoom_level = ? AND tile_column = ? AND tile_row = ?
V/sqlg    (17723): sqlc_st_bind_text_native 0xb8dec830 1 2
V/sqlg    (17723): sqlc_st_bind_text_native 0xb8dec830 2 1
V/sqlg    (17723): sqlc_st_bind_long 0xb8dec830 3 2
V/sqlg    (17723): sqlc_st_column_count 0xb8dec830
V/sqlg    (17723): sqlc_st_column_name 0xb8dec830 0
V/sqlg    (17723): sqlc_st_column_type 0xb8dec830 0
V/sqlg    (17723): sqlc_st_column_text_native 0xb8dec830 0
D/hardware_info(  243): hw_info_append_hw_type : device_name = speaker-lite
F/art     (17723): art/runtime/check_jni.cc:65] JNI DETECTED ERROR IN APPLICATION: input is not valid Modified UTF-8: illegal start byte 0x8b
F/art     (17723): art/runtime/check_jni.cc:65]     string: ''
F/art     (17723): art/runtime/check_jni.cc:65]     in call to NewStringUTF
F/art     (17723): art/runtime/check_jni.cc:65]     from java.lang.String io.liteglue.SQLiteNative.sqlc_st_column_text_native(long, int)```

DB already existing in apps sandboxed file storage

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.

Android Issue

I installed the plugin without problems on iOS following the documented steps.
Following the same steps on Android leads to an app crashing immediately after launch.

When I use the most recent version of https://github.com/litehelpers/cordova-sqlite-storage.git
rather then the 0.7.10 version I am able to launch the example.

changing to 0.7.10 again, makes the app crash on launch again.

Sqllite problem

Hi I have a following problem when cordova project is emalated on android device:

this is a error message from chrome devtool:
Database Error: sqlite3_prepare_v2 failure: no such table: tiles

It seems like the sqlite ext plugin for cordova can not work with "views".

How do I create the .mbtile file?

Pretty sure I'm being stupid here but how do I create the mbtile file? I've dug around in Mapbox Studio but can't see any way to define an area / zoom levels and export?

raster layers not showing

This example is working wonderfully for vector layers, but I'm not managing to get it to work with an mbtiles file containing a raster layer. Nothing is showing up, just a blank white map, and no errors are shown. This is with a file called smaller.mbtiles in the www directory.

For example this:
var mapStyle = {
"version": 8,
"sources": {
"smaller": {
"type": "raster",
"tiles": [
"{z}/{x}/{y}"
],
"minzoom": 2,
"maxzoom": 15
}
},
"layers": [
{
"id": "smaller",
"type": "raster",
"source": "smaller",
"source-layer": "selection" /* I tried without a source-layer specified as well */
}
]
};

I've noticed that with vector layers I get this text output in XCode:
"open full db path: /Users/[...]/[filename].mbtiles"

But with raster layers I don't get that line. How do I get this to work with raster layers?

Example does not display map and there is no error in Xcode console

EDIT:
there is an error in the Safari debugger:

[Log] OPEN database: naturalearth.mbtiles (SQLitePlugin.js, line 174)
[Log] DB opened: naturalearth.mbtiles (SQLitePlugin.js, line 79)
[Log] Database Error: no such table: tiles (mapbox-gl.js, line 94)
[Error] Failed to load resource: The requested URL was not found on this server. (mapbox-gl.js.map, line 0)
[Log] Database Error: no such table: tiles (mapbox-gl.js, line 94, x3)

I try to run your example but it display the +/-/compass icons and a black screen. There is no error in Xcode console.
Here is my config:
Xcode 7.1.1
iOS Simulator 9.1(13B137)

I followed the instruction here: https://github.com/trevorpowell/mapbox-gl-js-cordova-offline-example

Here is the console log:

2015-12-06 17:44:21.037 offlinemap[6673:405079] Apache Cordova native platform version 3.9.2 is starting.
2015-12-06 17:44:21.038 offlinemap[6673:405079] Multi-tasking -> Device: YES, App: YES
2015-12-06 17:44:21.058 offlinemap[6673:405079] Unlimited access to network resources
2015-12-06 17:44:21.073 offlinemap[6673:405079] 

Started backup to iCloud! Please be careful.
Your application might be rejected by Apple if you store too much data.
For more information please read "iOS Data Storage Guidelines" at:
https://developer.apple.com/icloud/documentation/data-storage/
To disable web storage backup to iCloud, set the BackupWebStorage preference to "local" in the Cordova config.xml file

2015-12-06 17:44:29.757 offlinemap[6673:405079] Resetting plugins due to page load.
2015-12-06 17:44:31.767 offlinemap[6673:405079] Finished load of: file:///Users/vikti/Library/Developer/CoreSimulator/Devices/D8AE46DE-ABEF-409A-ABCE-D509C12103D1/data/Containers/Bundle/Application/9A939BA2-EDF7-48F1-A7A4-EDBB22630A2D/offlinemap.app/www/index.html
2015-12-06 17:44:32.811 offlinemap[6673:405079] Initializing SQLitePlugin
2015-12-06 17:44:32.811 offlinemap[6673:405079] Detected docs path: /Users/vikti/Library/Developer/CoreSimulator/Devices/D8AE46DE-ABEF-409A-ABCE-D509C12103D1/data/Containers/Data/Application/DC41040F-0EAF-4021-AF99-34503A76B8FE/Documents
2015-12-06 17:44:32.812 offlinemap[6673:405079] Detected Library path: /Users/vikti/Library/Developer/CoreSimulator/Devices/D8AE46DE-ABEF-409A-ABCE-D509C12103D1/data/Containers/Data/Application/DC41040F-0EAF-4021-AF99-34503A76B8FE/Library
2015-12-06 17:44:32.812 offlinemap[6673:405079] no cloud sync at path: /Users/vikti/Library/Developer/CoreSimulator/Devices/D8AE46DE-ABEF-409A-ABCE-D509C12103D1/data/Containers/Data/Application/DC41040F-0EAF-4021-AF99-34503A76B8FE/Library/LocalDatabase
2015-12-06 17:44:32.816 offlinemap[6673:405079] open full db path: /Users/vikti/Library/Developer/CoreSimulator/Devices/D8AE46DE-ABEF-409A-ABCE-D509C12103D1/data/Containers/Data/Application/DC41040F-0EAF-4021-AF99-34503A76B8FE/Library/LocalDatabase/naturalearth.mbtiles
2015-12-06 17:44:32.829 offlinemap[6673:405079] Good news: SQLite is thread safe!
2015-12-06 17:44:32.831 offlinemap[6673:405079] THREAD WARNING: ['SQLitePlugin'] took '18.434082' ms. Plugin should use a background thread.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.