jcrowson
jcrowson

Reputation: 4290

Displaying Longitude and Latitude values stored in a SQLite db as a Route on a MapView in Android (Not Real Time)

I am currently in the process of creating an application that records current location of a mobile device in intervals, displaying the route as a coloured line on the device in real-time. At the same time the application is storing the longitude and latitude in a SQLite database as I want the user to be able to bring up that specific route again.

The route has a primary key and each waypoint is linked to that route by a foreign key.

What would be the easiest way to display the saved route on the map?.

Upvotes: 0

Views: 1788

Answers (2)

jcrowson
jcrowson

Reputation: 4290

Would I be able to create a cursor with all the waypoint values for a particular track then use a loop and the moveToNext(); method to move through the cursor, adding the overlay for each? for example:

int i = 0;

 do { 
      i++; 

      Cursor cursor = db1.query(TABLE_NAME, FROM, null, null, null, null,
            ORDER_BY);
    Double lat = cursor.getDouble(2);
    Double lon = cursor.getDouble(1);
    cursor.moveToNext();
    overlay.addGeoPoint( new GeoPoint( (int)(lat*1E6),  (int)(lon*1E6)));

 } while ....

Upvotes: 0

Praveen
Praveen

Reputation: 91175

check out this example....

Upvotes: 1

Related Questions