posm / OpenMapKitAndroid

http://openmapkit.org
BSD 3-Clause "New" or "Revised" License
128 stars 38 forks source link

nanohttpd serve mbtiles locally #124

Closed hallahan closed 8 years ago

hallahan commented 8 years ago

Since neither MapboxGL, TangramES, nor Maply Android have MBTiles support at the current moment, we can instead locally serve tiles from MBTiles via http. This would be a stopgap measure, but it should get us our map tiles without any noticeable difference.

nanohttpd is a popular nodejs-like Java http server, and it is commonly used to serve files on Android devices.

I tried the most basic hello world of just serving an index.html file in the project, and it works great:

https://github.com/AmericanRedCross/OpenMapKitAndroid/commit/e2870adbd94be45da9d5659d48e66dca9c738e9e

After a little bit of googling, I see that someone has done the same thing as an Apache Cordova plugin.

https://github.com/rgamez/cordova-plugin-http-mbtiles

It looks like it would be pretty simple to use what this cordova plugin is doing and modify it to work in a regular Android project

https://github.com/rgamez/cordova-plugin-http-mbtiles/blob/master/src/android/HTTPMBTilesServer.java

hallahan commented 8 years ago

This is a screenshot of a Leaflet map viewer on my laptop fetching tiles from the nano http MBTiles server on my Android phone through my local network:

screenshot 2016-01-19 13 30 51

This idea is proving fruitful.

hallahan commented 8 years ago

I'm content with the solution to this problem. I'm going to close, but if we need to add functionality as we implement our new map renderer, we can re-open.