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.
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'}); ... anno1.removeEventListener('myEvent',anno1); ...
–u
-
I use this, i'm doing a loop that creates my annotations, but then this allows it to fire just the one.
mapview.addEventListener('click',function(evt) { // 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