NullPointerException on Ti.Map.MapView.addAnnotation
Hello, I am getting a java.lang.NullPointerException when calling mapView.addAnnotation(annotation)
:
var annotation = Ti.Map.createAnnotation({
latitude: 37.77,
longitude: -122.41,
animate: true,
pincolor: Ti.Map.ANNOTATION_RED
});
Ti.API.info(typeof mapView);
Ti.API.info(typeof mapView.addAnnotation);
Ti.API.info(typeof annotation);
mapView.addAnnotation(annotation);
The three typeof
statements are yielding, respectively:
object
function
object
I'm running Titanium Developer 1.2.1 on OS X Snow Leopard with the APIs 2.2 SDK for Android (also tried APIs 2.1-update1).
Any thoughts?
I did find it unusual that http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Map.Annotation-object does not list latitude and longitude as properties of annotations, but example code includes them so I'm assuming this is an oversight in the API docs.
Thanks!
2 Answers
-
Hi, give me more details.
Are you using sdk 1.3.2 ? ( titanium 1.2.1 is just the cross compiler platform)
are u using iox 3.2.1 or later (4.0.1 )?Andrea
-
Here's the problem. I'm calling mapWin.open, immediately followed by mapView.addAnnotation. Even though the map window object exists, apparently the annotation can't add until the map is physically on the screen.