Code Monkey home page Code Monkey logo

offline_map_demo's Introduction

Android Offline Mapping Demo

This project is based on Phonegap + Leaflet + TileMill = Offline Mobile Maps by Geospatial Scott. In my case, I don't own an iOS device, and eventually want to have versions running in both iOS and Android, so I dove into the process of building an Android version of the demo.

This version uses the Android PhoneGap SQLite Plugin by brodyspark.

Notes

  • The SQLite Plugin has different method signatures and response objects than the one used by Geospatial Scott, and always operates in a transaction boundary
  • The SQLite Plugin always looks for database files in the path returned from "cordova.getActivity().getDatabasePath(dbname)" whereas the file download logic used in Geospatial Scott's demo uses the file system root path. I added two methods to the SQLite plugin to help mitigate this issue: 1) getDatabasePath, and 2) databaseExists. I probably could have just used getDatabasePath to check if the file exists, but this seemed a little cleaner.
  • The version of Leaflet.js I'm using is the latest (0.6), and the _loadTile and getTileUrl methods were changed from the version used by Geospatial Scott. Please note the _adjustTilePoint method in _loadTile - it's important!
  • After getting the map to load, I noticed very poor performance when panning and zooming - even on my device it would take several seconds to load tiles and render the map. I spent some quality time with traceview and determined that most of the time was spent converting the JSONArray object built from the database results into a string, which seemed very odd considering the array only contained one value - the map data. It turns out the JSONArray implementation that comes with Android writes the data to the string writer one character at a time. I modified the results2string method to use a StringBuilder instead and this proved MUCH faster. I'm still not at all happy with the performance when loading, panning, or zooming. Considering the fact that the tile data is being loaded from a local SQLite database, I expected it to be nearly instant, not slower than when using web-based maps from Google Maps since there is no network latency involved. I would REALLY appreciate help with the performance!

offline_map_demo's People

Contributors

dwinterbourne avatar

Stargazers

_truemen avatar  avatar Fredy R. Guibert フレディ avatar  avatar Juan Carlos Méndez avatar César Brandão avatar  avatar Satadru Bhattacharjee avatar Simon Thépot avatar Mathieu Leplatre avatar Gert-Jan Braas avatar Alper Dincer avatar js avatar Razvan avatar

Watchers

Razvan avatar Gert-Jan Braas avatar James Cloos avatar Andrew Feitosa avatar David Winterbourne avatar

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.