Issue
I have made an application in titanium framework for Google Maps. I have multiple locations on the map and which are shown as annotaion/pinpoints. I have taken click event of the annotation as well. Annotaions will show data in tableview in the next screen.when I am coming back to the Google Maps screen, I have to click back button twice rather than once.
Queries :
1) can any body help me out how to handle the back event which should come back by 1 click only instead of 2 clicks and which should not render the data 2 times on 2 clicks of back button.Here same screen appears 2 times for data on back button event.
2) If i have many annotations on the map, then how to get the information of the same/particular pinpoint/annotation , when it does the click event and should show data of pinpoint as tableview in the next screen.(i.e. if i have FOR LOOP and from that loop when it shows us the multiple annotation/pinpoint, all the annotation should get all the details and should shown its own data to the next screen tableview.)
Any useful code or link will be appreciated...!!!
I have given code snippet below :
mapview.addEventListener('click', function(evt) {
var annotation = evt.annotation;
var title = evt.title;
var clickSource = evt.clicksource;
// alert(annotation + 'tit'+title+'clickSource'+clickSource);
// alert("Btn Pressed");
if(evt.clicksource == 'rightButton') {
Titanium.App.Properties.setString("latitude",latitude.item(0).text);
Titanium.App.Properties.setString("longitude",longitude.item(0).text);
Titanium.App.Properties.setString("city",city.item(0).text);
Titanium.App.Properties.setString("address",address.item(0).text);
Titanium.App.Properties.setString("OwnerInstitution",OwnerInstitution.item(0).text);
Titanium.App.Properties.setString("TerminalDesc",TerminalDesc.item(0).text);
Titanium.App.Properties.setString("State",state.item(0).text);
Titanium.App.Properties.setString("Zip",Zip.item(0).text);
Titanium.App.Properties.setString("Charge",Charge.item(0).text);
var tab = Titanium.UI.currentTab;
var win1 = Titanium.UI.createWindow({
url:'ATMDetails.js',
title:'ATM Details',
// latitude:win1.latitude
});
tab.open(win1, {
animated:true
});
}
});
Solution
For Issue 1 I am not getting your point correctly.
For Issue 2- As i understand, you want to show the detail of particular annotaion where the user clicked. Solution: The function where you load all the information using for loop define an array which should store the data of specific anotaion. like
annotations = []; //updated
for (i=0; i < yourfeedsData.length; i++) {
var detailData= [];
//Your data
var latitude = latitude.item(0).text;
// all list of your data .......
// creating annotaions
var annotaion = Titanium.Map.createAnnotation( {
title:'Your title',
animate:true
});
// pushing the data to array ..... all your values like,
detailData.push({lat:latitude,...... });
// setting data to your annotaion object
annotaion.detailData=detailData;
// creating annotation array
annotations[i] = annotaion ; //updated
}
your_mapView.addAnnotations(annotations); // updated
and in your click event, get the annotation data and pass it to detail your window. And use that detail data to show in list.
// get the detail data
var detailData = evt.annotation.detailData;
if(evt.clicksource == 'rightButton') {
var tab = Titanium.UI.currentTab;
var win1 = Titanium.UI.createWindow({
url:'ATMDetails.js',
title:'ATM Details',
//latitude:win1.latitude
});
// PASS THE DATA TO YOUR WINDOW
win1 .detailData = detailData;
tab.open(win1, {
animated:true
});
}
Answered By - Muhammad Zeeshan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.