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;
}
}
You need to override onTap() method . Also Check this .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.