I'm currently making an android map based app. The purpose of this app is to display complex overlays on a mapview. To do this I'm using custom overlays and overriding draw()
function.
That part is working perfectly and now I'd like to handle onTap events for each overlay. What I'm currently doing:
public class MapOverlay extends Overlay {
public MapOverlay(Kml kml,String color,Projection projection){
}
public void draw(Canvas canvas, MapView mapv, boolean shadow){
super.draw(canvas, mapv, shadow);
// draw path...
}
@Override
public boolean onTap(GeoPoint gp, MapView mapView) {
Log.i("Overlay","Say whaaaat!");
return super.onTap(gp, mapView);
}
}
As expected, each overlay is covering the entire mapview, so when I tap on an overlay, every overlays fire the onTap event. Say I have 6 overlay, I can't tell which path has been tapped on.
Is there a solution to do that?
UPDATE:
Now I've succeeded displaying markers on my map using ItemizedOverlay (tied ItemizedBaloonOverlay as well) but it's not exactly what I want.
I'd like something like a PolygonOverlay that will detect if the tap was done inside the polygon and only fire a tap event in that case.
Thanks