开发者

Android: Got right lat and long but markers are printed at the wrong place

I'm fetching all the 's stores in "Göteborg" and adding a marker on my mapView. The problem is that with this code my markers get all bunched up in Africa.

I've checked that coordinates is correct so it isnt that.

Anyone know what's the problem is?

    df = ((ClassHandler)getApplication()).getStoreDatabadeFa开发者_高级运维cade();

    Cursor plotstore = df.getAllStorePos("Göteborg");
    startManagingCursor(plotstore);
    plotstore.moveToFirst();

    while(plotstore.isAfterLast() == false){

        GeoPoint addStore = new GeoPoint(plotstore.getColumnIndex("lat"), plotstore.getColumnIndex("long"));
        //OverlayItem overlayitem = new OverlayItem(addStore, plotstore.getString(plotstore.getColumnIndex("_ID")), plotstore.getString(plotstore.getColumnIndex("ADDRESS")));
        OverlayItem overlayitem = new OverlayItem(addStore, plotstore.getString(plotstore.getColumnIndex("_id")), plotstore.getString(plotstore.getColumnIndex("address")));

        itemizedStoreOverlay.addOverlay(overlayitem);
        storeOverlays.add(itemizedStoreOverlay);
        plotstore.moveToNext();
    }


Doesn't getColumnIndex just return the index of the column within the cursor, rather than the value at that index? You seem to be using it correctly for the id:

plotstore.getString(plotstore.getColumnIndex("_id"))

but not for the lat and long:

plotstore.getColumnIndex("lat")

Try changing this (and the "long") to:

plotstore.getInt(plotstore.getColumnIndex("lat"))
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜