Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

annotation event listener issue

So I'm pulling in 2 separate annotations (a client and a user annotation) through a jsonreponse and plotting it on the map just fine. The issue im running into deals with the eventlistener for the annotations.

I have one annotation with a right and left button, and another annotation with just a right button. The problem is that while setting an eventlistener on an annotation, I'm unable to define which annotation im selecting.

So basically, regardless of which annotation I select, be it the client or the user annotation, the eventlistener activates for both of them.

— asked November 8th 2010 by Chris Nelson
  • annotation
  • mapview

2 Answers

  • don't know about annotations, so i guess:

    var anno1 = addEventListener('myEvent',function(e){ alert(e.foo); });
    var anno2 = addEventListener('myOtherEvent',function(e){ ... });
    Ti.App.fireEvent('myEvent',{foo: 'bar'});


    — answered November 8th 2010 by u no
  • I use this, i'm doing a loop that creates my annotations, but then this allows it to fire just the one.

        // map event properties
        var annotation = evt.annotation;
        var title = evt.title;
        var endLat=evt.annotation.latitude;
        var endLon=evt.annotation.longitude;
        var clickSource = evt.clicksource;
            if (clickSource=="rightButton")
          do stuff

    Basically you're going to reference things by evt

    — answered November 9th 2010 by Josh Lewis
    1 Comment
    • That's how I'm currently adding the event listener. But I'm unsure of howto specify which set of annotations the listener is on.

      — commented November 9th 2010 by Chris Nelson
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.