Annotation Click Events not working on Android

You must Login before you can answer or comment on any questions.

Using Android 2.3 SDK

I have a map with pins. Clicking the pin brings up an annotation, but clicking the annotation does nothing.

It works just fine in iOS.

Code is below

var annotation = Titanium.Map.createAnnotation(annotationParams);
 
            annotation.addEventListener('click', function(e) {
                if(e.clicksource == "title" || e.clicksource == "subtitle") {
                    var win1 = Titanium.UI.createWindow({
                        url:"club.js",
                        club_id:e.annotation.myid,
                        title:e.annotation.title,
                        hasChild:true
                    });
 
                    Titanium.UI.currentTab.open(win1,{animated:true});
                }
            });

2 Answers

Accepted Answer

Try removing hasChild:true - not sure why you would use that outside a tableview context. Or add rightButton:Titanium.UI.iPhone.SystemButton.DISCLOSURE to the annotation and add it to the eventlistener as clicksource == 'rightButton'

— answered 2 years ago by Troy Taylor
answer permalink
4 Comments
  • No dice. I will check kitchen sink and compare if it is working there.

    — commented 2 years ago by Nick Wallace

  • @Troy Taylor rightButton:Titanium.UI.iPhone.SystemButton.DISCLOSURE doesnt work on android

    — commented 2 years ago by Aaron Saunders

  • ANSWER!!!

    Adding the click event to mapview instead of annotation solved the problem!

    http://www.pastie.org/1756264

    — commented 2 years ago by Nick Wallace

  • Show 1 more comment

For me, it worked on android emulator with the code below:

mapView.addEventListener('click',function(e){
    if(e.clicksource=='rightPane'){
        var detailWin = Titanium.UI.createWindow({
            cliente:e.annotation.customVar,
            url:'windows/details.js',
            navBarHidden: true,
        });  
        detailWin.open({animate:true});
    }    
});

Your Answer

Think you can help? Login to answer this question!