Mix of mapping and OpenGL-ES 2.0 - Creating a scale bar- Java

Hi,
Firstly, apologies about the nature of this question, it is a mixture of mapping and OpenGL, at this point the two are part of the same solution and there are users here that have experience with both.

I have created a map with zoom functionality for Android. Spatialite is my database.

The next stage in development is to create a dynamic scale bar that can be used as a reference to distance.
Visually I would like to work similar to Google maps, as far as how it grows and shrinks. Except in Google maps it fades away after a couple of seconds, I would like it to remain.

[ATTACH=CONFIG]520[/ATTACH]

  1. The first issue is calculating the distance.
  2. The second is what distance I should be displaying at any particular zoom level.
  3. The third, designing the scale bar. I am thinking the scale bar gets drawn in OpenGL and will grow and shrink only on the horizontal, a text-box sitting just under it displaying the current distance.

So far I tried to display a text-box that held the distance from one side of the screen to the other (this was just a test). To do this each time a pinch zoom was performed, I queried the Spatialite database with the projection matrix variables (left, right, top) adding my offsets (used to bring the center of the map to the origin for precision purposes) as parameters. The query uses a distance between points function and returns a distance. However this is particularly slow and after about 1000 zooms, it crashes and restarts my program.

Not sure if this helps, I have access through querying Spatialite to the CRS (coordinate reference system) and libraries that comes with it are gdal, ogr, proj4, osr.

Other functionality that I am going to tie into this is scale points to the zoom level and enable and disabling buttons, but this comes later.

Would appreciate some advice on how to proceed.