Trying to resend this reply as I think it may not have gone through the
first time...

Steve

On Thu, Jun 24, 2010 at 11:24 AM, Steve Howard <[email protected]> wrote:

> I think the ideal usage would be something like this:
>
> public boolean onTap(GeoPoint point, MapView mapView) {
>  // first, let the superclass check if the event hit a marker; if so,
> it'll call onTap(index)
>  // if it returns true, that means onTap(index) returned true,
> meaning the event has been handled already
>  if (super.onTap(point, mapView)) {
>    return true;
>  }
>
>  // the event wasn't handled as a tap on an existing marker, so let's
> add a new marker
>  addNewMarkerAt(point);
>  return true;
> }
>
> public boolean onTap(int index) {
>  // an existing marker was tapped
>  // ...display info by whatever means are appropriate...
>  return true; // indicate that we've handled this tap, and it
> shouldn't propagate to other potential handlers
> }
>
> You can override both, but the key is to call the superclass
> implementation of onTap(GeoPoint, MapView) and examine its return
> value.
>
> Let me know if that helps.
>
> Steve
>
>
> On Thu, Jun 24, 2010 at 9:57 AM, Carlos Silva <[email protected]> wrote:
> > On Thu, Jun 24, 2010 at 17:49, TreKing <[email protected]> wrote:
> >>
> >> On Jun 15, 9:15 am, tfriest <[email protected]> wrote:
> >> > Does anyone know of a better way to do this?
> >>
> >> As you've seen, the maps documentation is pretty pathetic. What I know
> >> of the onTap functions has been gleamed from trial and error and
> >> experimentation. This is how I believe it works:
> >>
> >> onTap(int) determines whether the item at the specified index will
> >> handle tap events at all. If you return false, the other onTap
> >> function will always return false.
> >>
> >> onTap(Point, MapView) determines whether an item in the overlay was
> >> tapped given the touch point, if onTap(int) return true for it's
> >> index.
> >>
> >> OK, with that, what you can do is:
> >> return true for onTap(int) always.
> >> in onTap(Point, MapView) call through to the base implementation to
> >> determine if something was tapped. And that's it.
> >>
> >> public boolean onTap(point, mapview)
> >> {
> >>  boolean tapped = super.onTap(point, mapView);
> >>  if (tapped)
> >>  showInfo();
> >> else
> >>  dropNewItem(point);
> >>
> >> return true; // irrelevant if you only have one itemized overlay
> >> }
> >>
> >> Hope that helps.
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> >> Groups "Android Developers" group.
> >> To post to this group, send email to
> [email protected]
> >> To unsubscribe from this group, send email to
> >> [email protected]<android-developers%[email protected]>
> >> For more options, visit this group at
> >> http://groups.google.com/group/android-developers?hl=en
> >
> >
> > I don't really agree with this.
> > I use onTap(int) to detect if an overlayItem was clicked. And use
> > onTap(point, mapview) to handle every other click on the map. I use the
> > first to show a ballow, and the second to hide it.
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]<android-developers%[email protected]>
> > For more options, visit this group at
> > http://groups.google.com/group/android-developers?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to