我对这个问题很感兴趣——当地图上的内容(标记)被添加到另一个线程时,如何更新它们。问题在于 - 我在另一个线程中向地图添加标记,部分是为了避免减慢用户界面,因为这是创建标记来分析数据库所必需的。该程序似乎工作正常 - 但在设置标记后,他们不检查地图。为了显示它们以与卡片进行交互(触摸或更改比例)。这就是我想问的原因 - 是否可以通过添加标记来更新地图的内容?在我不是一个好的解决方案中启动规模变化。我希望能得到你的帮助。
*更新,但不工作*
public void onPostExecute(){
SQLiteDatabase placeDataBase = SQLiteDatabase.openDatabase("/data/data/expir.java.file/databases/PlaceDataBase",
null ,
0);
Cursor location_latitude = placeDataBase.query("AllInfo",new String[]{"LOCATION_LATITUDE"}, null, null, null, null, null);
location_latitude.moveToFirst();
Log.d("CREATE CURSOR 1", "lat");
Cursor location_longitude = placeDataBase.query("AllInfo", new String[]{"LOCATION_LONGITUDE"}, null, null, null, null, null);
location_longitude.moveToFirst();
Cursor location_name = placeDataBase.query("AllInfo", new String[]{"LOCATION_NAME"}, null, null, null, null, null);
location_name.moveToFirst();
Cursor vicinity = placeDataBase.query("AllInfo", new String[]{"VICINITY"}, null, null, null, null, null);
vicinity.moveToFirst();
Cursor id = placeDataBase.query("AllInfo", new String[]{"&&&&&&&&"}, null, null, null, null, null);
id.moveToFirst();
Log.d("CREATE CURSOR 2", "lon");
quantityPlace = location_latitude.getCount();
int a = 0;
for(int i=1;i<=quantityPlace;i++){
if((int)(location_latitude.getDouble(0)*1000000)>=myLocationLatitude-(3*8998)&&
(int)(location_latitude.getDouble(0)*1000000)<=myLocationLatitude+(3*8998)&&
(int)(location_longitude.getDouble(0)*1000000)>=myLocationLongitude-(6*8998)&&
(int)(location_longitude.getDouble(0)*1000000)<=myLocationLongitude+(6*8998)){
a++;
Drawable drawable1 = MyMapActivity.this.getResources().getDrawable(R.drawable.scoutgroup);
itemizedoverlay = new HelloItemizedOverlay(drawable1, MyMapActivity.this); ;
GeoPoint point1 = new GeoPoint((int)(location_latitude.getDouble(0)*1000000), (int)(location_longitude.getDouble(0)*1000000));
overlayitem = new OverlayItem(point1, location_name.getString(0), vicinity.getString(0));
itemizedoverlay.addOverlay(overlayitem);
mapOverlays.add(itemizedoverlay);
}
Log.d("INFO", location_latitude.getPosition()+"/"+quantityPlace);
location_latitude.moveToPosition(i);
location_longitude.moveToPosition(i);
location_name.moveToPosition(i);
vicinity.moveToPosition(i);
id.moveToPosition(i);
}
Log.d("On map view", a+" location(s)");
mapView.invalidate();
placeDataBase.close();
}