I am trying to draw a custom shape in Draw method of ItemizedOverlay. Is it possible to get onTap event for the shape drawn. Currently onTap works for default drawable/marker. How to make it work for the shape drawn in Draw method?
Asked
Active
Viewed 947 times
1 Answers
0
It looks like you can override the hittest method from itemized overlay.
Replace the method with a test to see if you hit your shape. Please post your solution here for others afterwards.
Here is the original android version
protected boolean hitTest(OverlayItem item, Drawable marker, int hitX, int hitY) {
Point eventPos = new Point(hitX, hitY);
Point itemHitPosOnDisplay = calculateItemPostionRelativeToDisplay(item.getPoint());
Point distance = Point.substract(eventPos, itemHitPosOnDisplay);
if (marker == null) {
marker = this.defaultMarker;
}
if (Math.abs(distance.x) < marker.getIntrinsicWidth() / 2
&& Math.abs(distance.y) < marker.getIntrinsicHeight() / 2) {
return true;
}
return false;
}
Regards, Stéphane

Snicolas
- 37,840
- 15
- 114
- 173
-
Yes this works for default marker, but not for the drawing on canvas. – user626035 Jun 03 '11 at 17:49
-
let me rephrase it, can I make the canvas drawing as default marker? – user626035 Jun 03 '11 at 17:49
-
I don't know if you understood what I proposed. But did you *override* the method I mentionned ? What did you try ? – Snicolas Jun 03 '11 at 20:51