xonegirlz
xonegirlz

Reputation: 8977

adding click listener to Overlay class

I have the following class which extends Overlay that draws the pin in my Google Map, the question is how do I add a click listener on that so when I click on the pin I can redirect it to a different activity?

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

Upvotes: 0

Views: 549

Answers (1)

Arun Badole
Arun Badole

Reputation: 11097

You need to override onTap() method . Also Check this.

Upvotes: 1

Related Questions