[TIMOB-918] MapView.addAnnotation not working outside callbacks
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2011-04-17T01:54:39.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 1.4.0 |
Components | iOS |
Labels | annotations, map, maps |
Reporter | Matthew Lieder |
Assignee | Reggie Seagraves |
Created | 2011-04-15T02:39:10.000+0000 |
Updated | 2011-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.
Sadly still a problem using Titanium SDK 1.3.0
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.
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
(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...
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.