【发布时间】:2010-08-25 15:10:34
【问题描述】:
我有以下代码,它从数据库中获取信息并将其绘制在地图上。信息在那里并且可点击,但实际图标androidmarker 不可见。为什么?我该如何解决这个问题?
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tweets = new LocationData(this);
mapView = (MapView) findViewById(R.id.mapView);
mapView.setSatellite(true);
mc = mapView.getController();
mc.setZoom(17);
mapView.setBuiltInZoomControls(true);
// Add the MyPositionOverlay
positionOverlay = new MyPositionOverlay();
List<Overlay> overlays = mapView.getOverlays();
overlays.add(positionOverlay);
//Add the Mapitems Overlay.
mapOverlays = mapView.getOverlays();
Drawable drawable = this.getResources().getDrawable(R.drawable.androidmarker);
itemizedoverlay = new Mapitems(drawable, this);
mylocation();
distance(lat,lng);
addmark();
mapView.invalidate();
}
public void addmark(){
SQLiteDatabase db = tweets.getWritableDatabase();
String count = "SELECT * FROM tweets;";
Cursor mcursor = db.rawQuery(count, null);
startManagingCursor(mcursor);
mcursor.moveToFirst();
if(mcursor != null && mcursor.moveToFirst())
{
do
{
System.out.println("WHAT");
String tname = mcursor.getString(4);
String tmessage = mcursor.getString(7);
Double tlat = mcursor.getDouble(1);
System.out.println("lat" + tlat);
Double tlng = mcursor.getDouble(2);
System.out.println("lng" + tlng);
GeoPoint point = new GeoPoint(
(int) (tlat*1E6),
(int) (tlng*1E6));
OverlayItem overlayitem = new OverlayItem(point, tname, tmessage);
itemizedoverlay.addOverlay(overlayitem);
mapOverlays.add(itemizedoverlay);
}while(mcursor.moveToNext());
}
}
【问题讨论】:
-
是屏幕上的 tlat 和 tlng 像素还是地理点?看起来它们不是地理点,您需要使用地图投影在 (x,y) 和 (lat,lng) 之间进行映射
-
它们绘制正确。当我点击屏幕上的那个点时,它应该是弹出框出现的地方。它只是没有图标可以明显识别它。
标签: java android google-maps