得到的SQLite数据库Geopoints [英] Get Geopoints from SQlite DB

查看:131
本文介绍了得到的SQLite数据库Geopoints的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个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的开发者谷歌集团,因为的您选择跨帖子


  1. 传递一个光标你的 ItemizedOverlay 包含您的坐标,从数据库中检索。


  2. 实施尺寸() ItemizedOverlay 返回 getCount将() 光标


  3. 实施的getItem() ItemizedOverlay moveToPosition()光标,读出经纬度,转换为微度,创建一个的GeoPoint ,并将其返回


  4. 使用 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:

  1. Pass a Cursor to your ItemizedOverlay that contains your coordinates, retrieved from your database

  2. Implement size() in your ItemizedOverlay to return getCount() from the Cursor

  3. Implement getItem() in your ItemizedOverlay to moveToPosition() on the Cursor, read out the latitude and longitude, convert to microdegrees, create a GeoPoint, and return it

  4. Use the ItemizedOverlay on your MapView

这篇关于得到的SQLite数据库Geopoints的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆