| GitHub Issue | n/a |
| Type | Bug |
| Priority | High |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2012-04-04T09:41:02.000+0000 |
| Affected Version/s | Release 1.8.0.1, Release 2.0.0 |
| Fix Version/s | Release 2.0.0, Sprint 2012-06 |
| Components | iOS |
| Labels | module_map, parity, qe-testadded |
| Reporter | Francisco Antonio Duran Ramirez |
| Assignee | Sabil Rahim |
| Created | 2012-01-25T11:01:20.000+0000 |
| Updated | 2012-04-04T09:41:02.000+0000 |
Problem
Annotation eventListener firing only twice
Reproducible steps:
1. Run the code below in iOs.
Please see the attached video: iOS-1.9.0.v20120111233134 CI Build-5.0.1 iOS SDK
2. Run the code below in Android
Please see the attached video: Android-1.9.0.v20120111233134 CI Build-Android 2.3.3
Notice that in Android. You can press the Detail button several times, and the message of the alert
is still appearing.
Expected behavior:
Customer wants to have the same behavior in iOS like the video:
Android-1.9.0.v20120111233134 CI Build-Android 2.3.3
Tested with the next specs:
Simulator
Android version : 2.3.3
iPhone 4
Version of the device: 5.0.1
Titanium Studio, build: 1.0.9.201201240756
Titanium SDK: 1.8.0.1 & 1.9.0.v20120111233134
Samsung Fit
Android version of the device: 2.2.1
Code:
var win = Ti.UI.createWindow(
{
title : 'Annotations'
});
var addButton= Ti.UI.createButton(
{
style : Ti.UI.iPhone.SystemButton.PLAIN,
title : 'Add Annotation',
color : 'black',
width : 130,
height : 32,
top:5
});
var myMap = Titanium.Map.createView(
{
mapType : Titanium.Map.STANDARD_TYPE,
region : {latitude: 37, longitude: -97,latitueDelta: 10, longitudeDelta: 10},
animate : true,
regionFit : true,
userLocation : false,
});
win.add(myMap);
win.add(addButton);
addButton.addEventListener('click', function()
{
var x = 10
var lat = 37.422502;
var lon = -122.08554998;
for(i = 0; i < x; i++)
{
var myButton = Ti.UI.createButton(
{
//style : Ti.UI.iPhone.SystemButton.INFO_DARK,
title : 'Detalis',
height : 32,
width : 70,
id : i
});
myButton.addEventListener('click', function()
{
alert(this.id);
});
var myAnnotation = Ti.Map.createAnnotation(
{
latitude : lat,
longitude : lon,
title : 'Google HQ ',
subtitle : 'sdfsda',
animate : true,
pincolor : Ti.Map.ANNOTATION_RED,
leftView : myButton
});
myMap.addAnnotation(myAnnotation);
lat += 1.3*0.3;
lon += 2.5*0.1;
}
});
win.open();
Helpdesk
APP-526569
Workaround:
var win = Ti.UI.createWindow({ title : 'Annotations' }); var addButton= Ti.UI.createButton({ style : Ti.UI.iPhone.SystemButton.PLAIN, title : 'Add Annotation', bottom : '5dp', color : 'black', width : 130, height : 32, left : 0 }); var myMap = Titanium.Map.createView({ mapType : Titanium.Map.STANDARD_TYPE, region : {latitude: 37, longitude: -97, latitueDelta: 10, longitudeDelta: 10}, animate : true, regionFit : true, userLocation : false, }); win.add(myMap); win.add(addButton); //create an array to store annotations var myAnnotations = []; addButton.addEventListener('click', function(){ var x = 10 var lat = 37.422502; var lon = -122.08554998; for(i = 0; i < x; i++){ var myButton = Ti.UI.createButton({ title : 'Detalis', height : 32, width : 70, id : i }); myButton.addEventListener('click', function(){ alert(this.id); }); var myAnnotation = Ti.Map.createAnnotation({ latitude : lat, longitude : lon, title : 'Google HQ ', subtitle : 'sdfsda', animate : true, pincolor : Ti.Map.ANNOTATION_RED, leftView : myButton }); //store annotation into array myAnnotations.push(myAnnotation); lat += 1.3*0.3; lon += 2.5*0.1; } //add annotation array to map myMap.addAnnotations(myAnnotations); }); win.open();PR #1735 merged.
additional test case
var win = Ti.UI.createWindow( { title : 'Annotations' }); var addButton= Ti.UI.createButton( { style : Ti.UI.iPhone.SystemButton.PLAIN, title : 'Add Annotation', color : 'black', width : 130, height : 32, right : 5, top:5 }); var myMap = Titanium.Map.createView( { mapType : Titanium.Map.STANDARD_TYPE, region : {latitude: 37, longitude: -97,latitueDelta: 10, longitudeDelta: 10}, animate : true, regionFit : true, userLocation : false, }); win.add(myMap); win.add(addButton); addButton.addEventListener('click', function() { var x = 10 var lat = 37.422502; var lon = -122.08554998; for(i = 0; i < x; i++) { var myButton = Ti.UI.createButton( { //style : Ti.UI.iPhone.SystemButton.INFO_DARK, title : 'Detalis', height : 32, width : 70, id : i }); myButton.addEventListener('click', function() { alert(this.id); }); var myAnnotation = Ti.Map.createAnnotation( { latitude : lat, longitude : lon, title : 'Google HQ ', subtitle : 'sdfsda', animate : true, pincolor : Ti.Map.ANNOTATION_RED, leftView : myButton }); myMap.addAnnotation(myAnnotation); lat += 1.3*0.3; lon += 2.5*0.1; } }); var setAnnotationButton = Ti.UI.createButton( { style : Ti.UI.iPhone.SystemButton.PLAIN, title : 'Set Annotation', color : 'black', width : 130, height : 32, left : 5, top:5 }); win.add(setAnnotationButton); setAnnotationButton.addEventListener('click', function() { var x = 10 var lat = 37.422502; var lon = -122.08554998; var annotationsArray =[]; for(i = 0; i < x; i++) { var myButton = Ti.UI.createButton( { //style : Ti.UI.iPhone.SystemButton.INFO_DARK, title : 'Detalis', height : 32, width : 70, id : i }); myButton.addEventListener('click', function() { alert(this.id); }); var myAnnotation = Ti.Map.createAnnotation( { latitude : lat, longitude : lon, title : 'Google HQ ', subtitle : 'sdfsda', animate : true, pincolor : Ti.Map.ANNOTATION_RED, leftView : myButton }); annotationsArray.push(myAnnotation); lat += 1.3*0.3; lon += 2.5*0.1; } myMap.setAnnotations(annotationsArray); }); var removeAllAnnotationButton = Ti.UI.createButton( { style : Ti.UI.iPhone.SystemButton.PLAIN, title : 'Remove Annotation', color : 'black', width : 130, height : 32, top:50 }); win.add(removeAllAnnotationButton); removeAllAnnotationButton.addEventListener('click', function() { myMap.removeAllAnnotations(); }); win.open();Closing bug. Annotation eventListener gets fired any number of times. Verified fix on: SDK build: 2.0.0.v20120319003254 Titanium Studio, build: 2.0.0.201203182248 Device: Simulator, Android(v 2.3.3),iPhone 4(v 5.0.1), Nexus1(v 2.2)
Reopening/closing to add/remove labels