Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

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);

The three typeof statements are yielding, respectively:


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.


— asked July 26th 2010 by Ryan McKillen
  • annotations
  • maps
  • nullpointer

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 )?


    — answered July 26th 2010 by Andrea S
    • Thanks. I'm developing a mobile app with Titanium SDK version 1.3.0 (on Titanium Developer 1.2.1). iox? Do you mean iOs? I have SDK versions 3.2 and 4.0 installed, but I am not trying to build for iPhone. This question is about Android.

      — commented July 26th 2010 by Ryan McKillen
    • If the Titanium mobile SDK 1.3.0 is not the current version, what is? Where can I download it? The website doesn't have anything about versions. Although, according to the API docs, addAnnotion was introduced in 0.8 so I don't think that's the problem unless it has to be fixed (I guess that's likely).

      — commented July 26th 2010 by Ryan McKillen
  • 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.

    — answered July 26th 2010 by Ryan McKillen
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.