Show Google Map View Tab - Delay in Loading Markers from Geocoding?
I have a tab in my tab based app which shows Google Maps. It loads a number of markers for about 60 places using geo-coding via a JSON based method.
The problem is that when you click on the tab the view doesn't change until all the places have been loaded. Is there anyway I can show the map view instantly and then let the app update all the places ?
I have pasted the开发者_如何学编程 way I am creating the markers below :
while (mCursor.moveToNext()) {
Address = mCursor.getString(4);
Name = mCursor.getString(0);
String noSpaces = Address.replaceAll(" ", "+");
JSONObject geocoded = getLocationInfo(noSpaces);
GeoPoint point = getGeoPoint(geocoded);
List<Overlay> mapOverlays = mapView.getOverlays();
Drawable drawable = this.getResources().getDrawable(R.drawable.pushpin);
CustomizedItemOverlay itemizedOverlay =
new CustomizedItemOverlay(drawable, this);
OverlayItem overlayitem =
new OverlayItem(point, Name, Address);
itemizedOverlay.addOverlay(overlayitem);
mapOverlays.add(itemizedOverlay);
}
Just use the AsyncTask and inside doInBackground make search and inside onPostExecute that will get result from doInBackground make overlays insertion process.
精彩评论