我在谷歌地图 API V2 android 中显示多个标记。在我的代码下面,progressdialog 挂起,listmodelUserTrackings 有 448 个数据显示在地图上。请帮我解决这个问题。提前感谢
int i=0;
public void showMarker() {
showProgressDialog();
final Handler mHandler = new Handler();
new Thread(new Runnable() {
@Override
public void run() {
while (true) {
if (i < listmodelUserTrackings.size()) {
int pos = i;
Log.v("log_tag", "thread sleep");
final double lat = Double
.parseDouble(listmodelUserTrackings.get(pos)
.getLAT());
final double lng = Double
.parseDouble(listmodelUserTrackings.get(pos)
.getLONG());
Bundle bundle = new Bundle();
bundle.putDouble("lat", lat);
bundle.putDouble("longi", lng);
mHandler.post(new Runnable() {
@Override
public void run() {
String city = null;
try {
city = getAddress(lat,lng).get(0).getAddressLine(1);
} catch (NullPointerException e) {
}
if (city != null) {
CameraUpdate center = CameraUpdateFactory.newLatLng(new LatLng(
lat,lng));
mMap.addMarker(new MarkerOptions().position(
new LatLng(lat,lng)).title(
city));
mMap.moveCamera(center);
}
}
});
i++;
} else {
mHandler.post(new Runnable() {
@Override
public void run() {
dismissProgressDialog();
}
});
break;
}
}
}
}).start();
}