Search code examples
uitableviewtitaniummkannotationview

Open map annotation on table row click? on Titanium


I am new to Titanium and in the process of making my first iOS app using Titanium but I've hit a wall with a use case.

I am trying to open an annotation on the map by clicking on a particular row on a table view. I haven't had much success with this and was unable to find any help online. Is this impossible to do or am I just doing something wrong? The following is my code:

table.addEventListener('click', function (event) {
    Ti.API.info("Index of row that is clicked: "+event.index);
    globals.annos[event.index].fireEvent('click');
});

'table' is my TableView with a bunch of rows and global.annos[] is my array of annotations.

My objective is to open the annotation corresponding to the index of the table row that I have clicked. The above code doesn't achieve anything. I thought firing the 'click' event of the annotation would open the annotation but clearly I was mistaken.

Could someone help me out here? Any help would be much appreciated.


Solution

  • SOLVED! Lack of reading the docs more thoroughly!

    mapview.selectAnnotation(globals.annos[event.index]);
    

    This opens the corresponding annotation.