Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-7396] iOS: Annotation eventListener firing only twice

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-04-04T09:41:02.000+0000
Affected Version/sRelease 1.8.0.1, Release 2.0.0
Fix Version/sRelease 2.0.0, Sprint 2012-06
ComponentsiOS
Labelsmodule_map, parity, qe-testadded
ReporterFrancisco Antonio Duran Ramirez
AssigneeSabil Rahim
Created2012-01-25T11:01:20.000+0000
Updated2012-04-04T09:41:02.000+0000

Description

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

Attachments

FileDateSize
Android-1.9.0.v20120111233134 CI Build-Android 2.3.3.mov2012-01-25T11:01:20.000+00006528702
iOS-1.9.0.v20120111233134 CI Build-5.0.1 iOS SDK.mov2012-01-25T11:01:20.000+00002360545

Comments

  1. Francisco Antonio Duran Ramirez 2012-01-26

    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();
       
       
  2. Neeraj Gupta 2012-03-18

    PR #1735 merged.
  3. Sabil Rahim 2012-03-18

    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();
       
  4. Anshu Mittal 2012-03-19

    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)
  5. Michael Pettiford 2012-04-04

    Reopening/closing to add/remove labels

JSON Source