得到的SQLite数据库Geopoints [英] Get Geopoints from SQlite DB
问题描述
我创建了一个SQLite数据库来存储所有的纬度和经度在地图上显示出来。对于价值的附加我没有任何encouter问题,我用这个code:
CoordBD CoordBd =新CoordBD(本);
Coordo coordo =新Coordo(36.869686,10.315642);
CoordBd.open();
CoordBd.insertCoordo(coordo);
但我不知道该如何接一个地映射到它们插入一个,我通常是/手动进行这样的:
的GeoPoint点2 =新的GeoPoint(微度(36.86774),微度(10.305302));
pinOverlay.addPoint(点2);
如何浏览所有的数据库,并自动添加所有Geopoints?
谢谢。
修改:这是真的
CoordBD CoordBd =新CoordBD(本);
CoordBd.open();
Coordo coordo =新Coordo(36.869686,10.315642);
CoordBd.insertCoordo(coordo);
CoordBd.close(); maMap =(图形页面)findViewById(R.id.myGmap);
maMap.setBuiltInZoomControls(真);
ItemizedOverlayPerso pinOverlay =新ItemizedOverlayPerso(getResources()getDrawable(R.drawable.marker)); 的String [] = result_columns新的String [] {COL_LATI,COL_LONGI};
光标CUR = db.query(真,TABLE_COORD,result_columns,
NULL,NULL,NULL,NULL,NULL,NULL);
cur.moveToFirst();
而(cur.isAfterLast()== FALSE){
INT纬度= cur.getColumnIndex(纬度);
INT经度= cur.getColumnIndex(经度);
的GeoPoint点=新的GeoPoint(微度(纬度),微度(经度));
pinOverlay.addPoint(点);
cur.moveToNext();
}
cur.close();
引用自己从我的回答对你的 Android的开发者
谷歌集团,因为的您选择跨帖子:
-
传递一个
光标
你的ItemizedOverlay
包含您的坐标,从数据库中检索。 -
实施
尺寸()
在ItemizedOverlay
返回getCount将()
从光标
-
实施
的getItem()
在ItemizedOverlay
到moveToPosition()
在光标
,读出经纬度,转换为微度,创建一个的GeoPoint
,并将其返回 -
使用
ItemizedOverlay
在图形页面
I created an SQlite database to store on it all latitudes and longitudes to display them in map. For the add of the values i didn't encouter any problem, i used this code:
CoordBD CoordBd = new CoordBD(this);
Coordo coordo = new Coordo(36.869686,10.315642 );
CoordBd.open();
CoordBd.insertCoordo(coordo);
But i don't know how to insert them one by one in map, i usually/manually make this:
GeoPoint point2 = new GeoPoint(microdegrees(36.86774),microdegrees(10.305302));
pinOverlay.addPoint(point2);
How to browse all the database and add all the Geopoints automatically? Thank you. EDIT: Is that true?
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();
Quoting myself from my reply to you on the android-developers
Google Group, since you elected to cross-post:
Pass a
Cursor
to yourItemizedOverlay
that contains your coordinates, retrieved from your databaseImplement
size()
in yourItemizedOverlay
to returngetCount()
from theCursor
Implement
getItem()
in yourItemizedOverlay
tomoveToPosition()
on theCursor
, read out the latitude and longitude, convert to microdegrees, create aGeoPoint
, and return itUse the
ItemizedOverlay
on yourMapView
这篇关于得到的SQLite数据库Geopoints的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!