将Click监听器添加到Overlay类

时间:2011-11-29 05:22:59

标签: java android

我有以下类扩展Overlay,在我的Google Map中绘制引脚,问题是我如何添加点击监听器,所以当我点击pin时我可以将它重定向到另一个活动?

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;
        }
    } 

1 个答案:

答案 0 :(得分:1)

您需要覆盖onTap()方法。 还Check this