我有以下扩展了Overlay的类,该覆盖层在我的Google Map中绘制了图钉,问题是如何在该图钉上添加点击侦听器,因此当我单击图钉时,可以将其重定向到其他活动吗?

class MapOverlay extends Overlay
    {
        private GeoPoint p;

        public MapOverlay(GeoPoint p){
            this.p = p;
        }

        public boolean draw(Canvas canvas, MapView mapView,
        boolean shadow, long when)
        {
            super.draw(canvas, mapView, shadow);

            //---translate the GeoPoint to screen pixels---
            Point screenPts = new Point();
            mapView.getProjection().toPixels(p, screenPts);

            //---add the marker---
            Bitmap bmp = BitmapFactory.decodeResource(
                getResources(), R.drawable.pushpin);
            canvas.drawBitmap(bmp, screenPts.x, screenPts.y-50, null);
            return true;
        }
    }

最佳答案

您需要重写onTap()方法。
也是Check this

10-04 19:17