【发布时间】:2011-07-29 08:29:07
【问题描述】:
这是我在 Google 地图中使用的覆盖类。我向它添加了两个标记,并希望为这些标记添加一个侦听器。下面是我的覆盖类:
protected class MyLocationOverlay extends com.google.android.maps.Overlay {
@Override
public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when) {
super.draw(canvas, mapView, shadow);
// Converts lat/lng-Point to OUR coordinates on the screen.
Point myScreenCoords = new Point();
mapView.getProjection().toPixels(p, myScreenCoords);
Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.passenger_map);
canvas.drawBitmap(bmp, myScreenCoords.x, myScreenCoords.y, null);
// canvas.drawText("I am here...", myScreenCoords.x, myScreenCoords.y, paint);
mapView.getProjection().toPixels(p1, myScreenCoords);
Bitmap bmp1 = BitmapFactory.decodeResource(getResources(), R.drawable.driver_map);
canvas.drawBitmap(bmp1, myScreenCoords.x, myScreenCoords.y, null);
// canvas.drawText(" Driver : I am here...", myScreenCoords.x, myScreenCoords.y, paint);
return true;
}
【问题讨论】:
标签: android android-maps