Issue
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();
}
}
Solution
Try calling:
invalidate()
from UI thread
or
postInvalidate()
from another thread
on your MapView object to make the map view repaint.
You should call mapOverlays.add(itemizedOverlay);
in onPostExecute(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.
Answered By - Tomasz
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.