我创建了一个SQlite数据库,将所有纬度和经度都存储在上面,以便在地图中显示它们。对于添加没有任何问题的值,我使用了以下代码:
CoordBD CoordBd = new CoordBD(this);
Coordo coordo = new Coordo(36.869686,10.315642 );
CoordBd.open();
CoordBd.insertCoordo(coordo);但是我不知道如何将它们逐一插入到地图中,我通常/手动地这样做:
GeoPoint point2 = new GeoPoint(microdegrees(36.86774),microdegrees(10.305302));
pinOverlay.addPoint(point2);如何浏览所有的数据库,并自动添加所有的地理点数?谢谢。编辑:这是真的吗?
CoordBD CoordBd = new CoordBD(this);
CoordBd.open();
Coordo coordo = new Coordo(36.869686,10.315642 );
CoordBd.insertCoordo(coordo);
CoordBd.close();
maMap = (MapView)findViewById(R.id.myGmap);
maMap.setBuiltInZoomControls(true);
ItemizedOverlayPerso pinOverlay = new ItemizedOverlayPerso(getResources().getDrawable(R.drawable.marker));
String[] result_columns = new String[] {COL_LATI, COL_LONGI};
Cursor cur = db.query(true, TABLE_COORD, result_columns,
null, null, null, null, null, null);
cur.moveToFirst();
while (cur.isAfterLast() == false) {
int latitude = cur.getColumnIndex("latitude");
int longitude = cur.getColumnIndex("longitude");
GeoPoint point = new GeoPoint(microdegrees(latitude),microdegrees(longitude));
pinOverlay.addPoint(point);
cur.moveToNext();
}
cur.close();发布于 2011-08-19 14:29:55
引用我在android-developers谷歌集团上给你的回复,因为你选择了跨岗
Cursor传递给包含您的坐标的ItemizedOverlay,该坐标从数据库中检索。size()中实现ItemizedOverlay以从Cursor返回getCount()getItem()中实现ItemizedOverlay到Cursor上的moveToPosition(),读出纬度和经度,转换成微度,创建一个GeoPoint,然后返回ItemizedOverlay上使用MapViewhttps://stackoverflow.com/questions/7121924
复制相似问题