this is my first question here, so if anything's wrong, do tell.
Now, I have a public class MainMap extends MapActivity
which uses a MyLocationListener
for the user's location and a HelloItemizedOverlay.
I'm getting certain POI's from an XML-file which I want to add markers (pretty basic Overlays).
User presses a button, AsyncTask starts:
private class GetPOITask extends AsyncTask<String, Void, Void> {
protected Void doInBackground(String... params) {
clearMapOverlay();
if(!isBusyAddingOverlays)
{
connect(params[0]);
}
return null;
}
protected void onPreExecute() {
clearMapOverlay();
}
}
Clearing out the MapOverlay (this.mv is a MapView):
public void clearMapOverlay()
{
this.mv.getOverlays().remove(placesItemizedOverlay);
this.mv.postInvalidate();
this.mv.getOverlays().add(myLoc);
}
This is the method that my connect-method calls when I have enough information to add a marker:
private void addOverlayToList(int id, GeoPoint point, String title, String description)
{
//Log.e("Debug", "Adding overlay");
placesItemizedOverlay.addOverlay(new POIOverlay(id, point, title, description));
this.mv.getOverlays().add(placesItemizedOverlay);
}
That should be all the relevant code.
The problem is that when I add the POI's and zoom the map (or move it), I get a ConcurrentModificationException
.
I've searched through this site, reading similar threads (this one for example) but I can't really find what I'm doing wrong.
Knowing myself, it's probably something obvious.
Thanks in advance,
iarwain