Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-957] Removing annotations from MapView breaks map evens

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2011-04-17T01:54:47.000+0000
Affected Version/sn/a
Fix Version/sRelease 1.4.0
ComponentsiOS
Labelsannotations, maps, mapview
ReporterGavin Joyce
AssigneeReggie Seagraves
Created2011-04-15T02:40:14.000+0000
Updated2011-04-17T01:54:47.000+0000

Description

Hi,

I've outlined the issue on Q&A: http://developer.appcelerator.com/question/26471/mapview-click-event-does-not-fire-after-changing-annotations"> http://developer.appcelerator.com/question/26471/mapview-click-even....

Calling mapview.removeAnnotations seems to break the mapview 'click' event listener.

The following reproduces the issue:

//create two sets of pins
var pins1 = [
  Titanium.Map.createAnnotation({ latitude:37.390749, longitude:-122.081651, title:"pins1: A" }),
  Titanium.Map.createAnnotation({ latitude:37.74511, longitude:-84.38993, title:"pins1: B" }),
];
 
var pins2 = [
  Titanium.Map.createAnnotation({ latitude:37.390749, longitude:-122.081651, title:"pins2: A" }),
  Titanium.Map.createAnnotation({ latitude:37.74511, longitude:-84.38993, title:"pins2: B" }),
];
 
var mapview = Titanium.Map.createView({
    mapType: Titanium.Map.STANDARD_TYPE,
    animate:true,
    userLocation:false,
    annotations:pins1 //the initial setup, both pins will handle click events correctly
});
mapview.addEventListener('click', function(e) {
  Ti.API.log('- mapview click event : ' + e.clicksource);
});
Ti.UI.currentWindow.add(mapview);
 
 
//add a button to change the pins
var changePins = Titanium.UI.createButton({
    title:'change pins',
    style:Titanium.UI.iPhone.SystemButtonStyle.BORDERED
});
 
changePins.addEventListener('click',function() {
  //removing the initial pins and adding the seconds set - the second pind does not fire the clicked event 
    mapview.removeAnnotations(pins1);
    mapview.addAnnotations(pins2);
});
 
Ti.UI.currentWindow.setToolbar([changePins]);

Comments

  1. Stephen Tramer 2011-04-15

    Works for me. I'll need confirmation from a second source to mark the bug as invalid - either this was fixed in 1.3.0 or as part of another event handling bug.

  2. Gavin Joyce 2011-04-15

    I've rechecked checked this on SDK 1.3.0 on my dev machine and the issue is present.

    I'm going to install a clean titanium on another mac and try there. I'll keep you posted.

  3. Gavin Joyce 2011-04-15

    I've just confirmed the bug in 1.3.0 on a clean install of Titanium.

    Just to be clear, here is what I'm seeing:

    On initial load, clicking the first pin results in two click events. Clicking on subsequent pins results in single click events. After clicking the 'change pins' button, only one pin raises click events. The second pin doesn't raise any events.

  4. Jeff Haynie 2011-04-15

    (from [3328be99875f5468f4c6fae0dd9a4358d63ac0bb]) Closes #957: Annotations now need refresh on creation. http://github.com/appcelerator/titanium_mobile/commit/3328be99875f5468f4c6fae0dd9a4358d63ac0bb"> http://github.com/appcelerator/titanium_mobile/commit/3328be99875f5...

JSON Source