Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-918] MapView.addAnnotation not working outside callbacks

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2011-04-17T01:54:39.000+0000
Affected Version/sn/a
Fix Version/sRelease 1.4.0
ComponentsiOS
Labelsannotations, map, maps
ReporterMatthew Lieder
AssigneeReggie Seagraves
Created2011-04-15T02:39:10.000+0000
Updated2011-04-17T01:54:39.000+0000

Description

I've been struggling to get MapView.addAnnotation working and now I'm pretty sure it's buggy. If I call addAnnotation immediately after creating the mapview it doesn't work, but if I instead call it from inside a click event listener for a button it works fine!

Here's how to reproduce the bug in Kitchen Sink's map_view.js:
1. In the mapview's creation, remove the atlanta annotation from the annotations array
2. Run the app and note that the annotation is now gone
3. Add "mapview.addAnnotation(atlanta);" immediately after the mapview creation
4. Run the app and note that the annotation is still gone
5. Find the atl button's event listener and replace its callback's contents with that addAnnotation call
6. Run the app, click the ATL button and note that inexplicably, the annotation now shows!

I'm using Mac OS 10.5, iPhone OS 3.1.3, Titanium Mobile 1.2.1, and Titanium SDK 1.2.0.

Comments

  1. Matthew Lieder 2011-04-15

    Sadly still a problem using Titanium SDK 1.3.0

  2. Matthew Lieder 2011-04-15

    Assigning to a developer to make sure this issue doesn't get missed. Stephen, I apologize if you're not the appropriate developer; I did my best guess.

  3. Yeggeps 2011-04-15

    I, too, have come across this problem. The same seems to apply to selectAnnotation.
    If I call it outside an Eventlistener, nothing happens, but works fine in a button.
    I also tried to use it within a focus event listener on the mapview and the window that contains the mapview, no success.

    like this

       win_map.addEventListener('focus',function(){
           mapview.selectAnnotation(name,true);
       });
       
       mapview.addEventListener('focus',function(){
           mapview.selectAnnotation(name,true);
       });
       
  4. Jeff Haynie 2011-04-15

    (from [64e7b513f714f82b2dafe91694ec43656dc365bb]) Closes #918: Map view functions now work before view is drawn. BUT: Be aware of the documentation change. This is a limitation of view drawing and the map kit combined. http://github.com/appcelerator/titanium_mobile/commit/64e7b513f714f82b2dafe91694ec43656dc365bb"> http://github.com/appcelerator/titanium_mobile/commit/64e7b513f714f...

  5. Stephen Tramer 2011-04-15

    Okay, this is fixed. But PLEASE be aware of the following precondition: You cannot call any methods on a map view until it has been added to another view. Otherwise crashes will result.

JSON Source