Open a window on Map annotation right button click event

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

I have a mapview whose annotations are pulled from an XML file.

var annot = Ti.Map.createAnnotation
({
    latitude:lat,
    longitude:lon,
    title:title,
    pincolor: Ti.Map.ANNOTATION_RED,
    rightButton: Titanium.UI.iPhone.SystemButton.DISCLOSURE,
    animate:true,
    myid:1 // CUSTOM ATTRIBUTE THAT IS PASSED INTO EVENT OBJECTS
});
This is my rightbutton click event
mapview.addEventListener('click',function(evt)
{
    // map event properties
    var annotation = evt.annotation;
    var title = evt.title;
    var clickSource = evt.clicksource;
    // custom annotation attribute
    var myid = evt.annotation.myid;
 
    // use custom event attribute to determine if atlanta annotation was clicked
    if (myid == 1 && evt.clicksource == 'rightButton')
    {
 
            //I want to open up a description page that is pulled from the same XML file but it's in Detail.js file
});
This is my sites.js which is coming from the same XML file
var find = Ti.UI.createView({
        top:0,
        bottom:45
        });
// create table view data object
var siteData = [];
var tableview3 = Ti.UI.createTableView({
    data: [],
    separatorColor:'#6fab70'
});
find.add(tableview3);
tableview3.addEventListener('click',function(e){
    if(!!e.rowData.tagName20){
    var win = Titanium.UI.createWindow({
            title:"Detailed Description",
            backgroundcolor:"#ffffff",
            barColor:"#6fab70",
            url:"Detail.js"
        });
    win.sitedesc = "Description: " +e.rowData.tagName10;
        win.title = e.rowData.tagName20;
        win.sitefullimage = e.rowData.image;
    Titanium.UI.currentTab.open(win,{animation:true});
   }
});
on tableview click event, it will open up a detailed description page 'Detail.js'
var win = Ti.UI.currentWindow;
 
var sitedesc = win.sitedesc;
var title = win.title;
var sitefullimage = win.sitefullimage;
//it has lables and views that will use the above variables.
So my question is, how do I display details in Detail.js file when corresponding annotation's rightbutton is clicked in mapview?

— asked 1 year ago by Nidhi Shah
4 Comments
  • why aren't you using the same code as the click event on the table row?

    — commented 1 year ago by Aaron Saunders

  • Because it's a different js file. The map is in map.js and this tableview is in site.js Can I still use the same code?

    — commented 1 year ago by Nidhi Shah

  • are you trying to display the same Details.js window?

    — commented 1 year ago by Aaron Saunders

  • Show 1 more comment

1 Answer

I did it like this

mapview.addEventListener('click', function(evt) { if (evt.clicksource == 'rightPane') { win.open()
}; }

but if you click the same rightbutton more than once it will freeze the win.close() function. can anybody help?

Your Answer

Think you can help? Login to answer this question!