Issue
What I want to do is adding GeoPoints on a google mapView. This is what my code now looks like:
public ArrayList getLocations() {
ArrayList<OverlayItem> locations = new ArrayList<OverlayItem>();
/* open SQLite database aanmaken als deze al dan niet bestaat */
SQLiteDatabase myDB = openOrCreateDatabase(DATABASE_NAME, Context.MODE_PRIVATE, null);
SharedPreferences preferences = getSharedPreferences("data", 0);
String route_id = String.valueOf( preferences.getInt("route_id", 0));
String[] resultColumns = new String[] { "_id", "route_id","naam", "lng", "lat" };
String whereClause = "route_id=?";
String[] whereArgs = new String[] {route_id};
Cursor cursor = myDB.query(DATABASE_TABLE_LOCATIES, resultColumns, whereClause,
whereArgs, null, null, null, null);
cursor.moveToFirst();
do {
String naam = cursor.getString(2);
Double lat = cursor.getDouble(4);
Double lon = cursor.getDouble(3);
GeoPoint point = new GeoPoint((int) (lat * 1E6),(int) (lon * 1E6));
locations.add(new OverlayItem(point, naam,naam));
} while (cursor.moveToNext());
return locations;
}
public void onCreate(Bundle savedInstanceState) {
InterestingLocations funPlaces = new InterestingLocations(marker);
mapView.getOverlays().add(getLocations);
}
This code is putting all my pointers at once on the mapView. I would like a small delay when putting each pointer on the map. How could I do this?
Thanks in advance
Solution
First define global variable,
private Timer myTimer;
add this inside onCreate()
method:
myTimer = new Timer();
myTimer.schedule(new TimerTask() {
@Override
public void run() {
TimerMethod();
}
}, 0, 1000);
}
and add this function in the class:
private void TimerMethod()
{
this.runOnUiThread(Timer_Tick);
}
and define this as global variable:
private Runnable Timer_Tick = new Runnable() {
public void run() {
//here is your job, instead of writing this [mapView.getOverlays().add(getLocations);]
//you have to create a loop for the list returned by getLocations() to add them in the timer one by one
}
};
Answered By - Hesham Saeed
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.