Home > Android, Maps, Programming > MapApp2 : App Design

MapApp2 : App Design

Welcome to the third part of my tutorial on how to create a map app for Android without using Google™ APIs :).

Series outline:


Okay, I’m supposed to show you a class diagram here but I changed my mind, since the app is simple I’ll explain each class in some lines :).

TilesManager: this class contains all the calculations needed to power our app, as I mentioned before maps are made up of tiles, we need to know exactly what tiles to fetch, we also need to convert latitude and longitude to pixel coordinates to display markers, this class by itself doesn’t contain the tiles, it just provides us with methods to know what tiles are visible and where to render them.

This class can be extremely easy to be written in JAVA without any Android libraries (I’m just using Android’s Rect and Point classes).

TilesProvider: receives a range of tiles indices (indexes ;)) then fetches the required tiles images, in our case the tiles are fetched from a database, to make an online map application you just need to change some functions in this class.

If you want your app to support both online and offline modes, extract an interface from this class and use it as your tile source, I think I’ll explain how to get tiles from OpenStreetMap later.

Fetching tiles from the database is time expensive, so we will add simple caching to this class , this also helps a lot when dealing with online map servers, caching in this case will save you both time and bandwidth, you’ll also save the tile servers some trouble :D.

MapView: a custom View that will ask a TilesManager (using location data) about what tiles we should render and where, then it asks a TilesProvider for the images of those tiles and finally renders them.

MapView will respond to touch events to enable panning.

Tile: each tile simply contains x,y index and a Bitmap (The actual image of the tile), no z or zoom index since we render one zoom level at a time.


Other classes exist and will be discussed when they are needed :).

In the next part of the tutorial we will start the actual coding :).

Categories: Android, Maps, Programming Tags: , ,
  1. 29/08/2012 at 12:22 am

    well, by adding a simple caching (actually not very sure about what exactly is that :)) to TileProvider class. Does it mean if I want to add a pin marker and display a route between my current location to that place is somehow not possible? 😀 Or if I want to do that I should do fetching tiles from the database?

    • Fuchs
      29/08/2012 at 7:26 pm

      If you want to display something in the map you don’t have to change anything in the TilesProvider.
      You don’t modify the tiles, you draw over them!

  2. 09/08/2014 at 12:16 pm

    hi Funchs,,,
    if i don’t use Mobile Atlas Creator,… instead I use the map
    exported from https://www.openstreetmap.org
    is it still can be use to the code Fuchs?

    • Fuchs
      12/08/2014 at 9:58 pm

      Hi, could you please send me the exported map data? maybe you can export a small portion of the map. I need to know what format is the data.

  1. No trackbacks yet.

What do you think?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: