I am having an issue with my mapview – I populate it with a AsyncTask, but after it completes the points don’t show up until the screen is tapped (after the first touch all the points show up properly).
Oncreate:
dialog = ProgressDialog.show(MyMap.this, “Populating Map”,
“Please wait…”, true);new AddOverlays().execute();
My AsyncTask:
class AddOverlays extends AsyncTask <Void, Void, String>{
@Override
protected String doInBackground(Void... unsued) {
//do my looping work to add items to map
mapOverlays.add(itemizedOverlay);
String nothing = "";
return nothing;
}
@Override
protected void onProgressUpdate(Void... unsued) {
}
@Override
protected void onPostExecute(String sResponse) {
if (dialog.isShowing())
dialog.dismiss();
}
}
Try calling:
invalidate()from UI threador
postInvalidate()from another threadon your MapView object to make the map view repaint.
You should call
mapOverlays.add(itemizedOverlay);inonPostExecute(String sResponse)as adding a new overlay is not an expensive operation.I suppose you will do some kind of expensive operation in
doInBackground(Void... unused)because as of right now you don’t really need the whole AddOverlays task.