1
public class TestActivity extends Activity implements OnMarkerClickListener{
static LatLng HAMBURG = new LatLng(53.558, 9.927);
static LatLng KIEL = new LatLng(53.551, 9.993);
private GoogleMap map;
Marker hamburg, kiel;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test);
map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))
.getMap();
hamburg = map.addMarker(new MarkerOptions().position(HAMBURG).title("Hamburg"));
kiel = map.addMarker(new MarkerOptions().position(KIEL).title("Kiel"));
Polyline line = map.addPolyline(new PolylineOptions().add(HAMBURG,KIEL).width(5).color(Color.RED));
// Move the camera instantly to hamburg with a zoom of 15.
map.moveCamera(CameraUpdateFactory.newLatLngZoom(HAMBURG, 15));
// Zoom in, animating the camera.
map.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);
AsyncTaskRunner runner = new AsyncTaskRunner();
runner.execute();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
private class AsyncTaskRunner extends AsyncTask<String, String, String> {
String result;ProgressDialog pdia;
@Override
protected String doInBackground(String... params) {
publishProgress("Loading..."); // Calls onProgressUpdate()
TestActivity.HAMBURG = new LatLng(3.190393, 101.651317);
TestActivity.KIEL = new LatLng(3.148443,101.577099);
return result;
}
@Override
protected void onPostExecute(String result) {
pdia.dismiss();
}
@Override
protected void onPreExecute() {
super.onPreExecute();
pdia = ProgressDialog.show(TestActivity.this, "Please wait", "Loading data from database.", true, false);
}
@Override
protected void onProgressUpdate(String... text) {
}
}
}
我需要執行的是將標記(HAMBURG和KIEL)更改爲異步任務中設置的位置。同樣在listview中,我使用notifydatachanged(),在這種情況下應該怎麼做?谷歌地圖片段異步任務完成後的片段更新/刷新
請擺脫一些光,並提前謝謝。
非常感謝! :d – user3153745