Search code examples
titanium

Titanium:Ti.Map is undefined?


I guess I must have done an update, since my app stopped working.

The line is simple enough:

var marker = Ti.Map.createAnnotation({
    latitude: json.objects[0].tour[e.index].locations[i].latitude,
    longitude: json.objects[0].tour[e.index].locations[i].longitude,
    title: json.objects[0].tour[e.index].locations[i].name,
    subtitle: json.objects[0].tour[e.index].locations[i].excerpt,
    animate: true,
    pincolor: Ti.Map.ANNOTATION_GREEN,
    leftButton: '../images/pointer.png',
    image: '../images/pointer.png'
});

But when I try to compile I get:

'undefined' is not an object (evaluating 'Ti.Map.createAnnotation')

I added the Ti.Map as a watch expression and it says it's undefined?

What did I do wrong?


Solution

  • Ti.Map was removed in 3.2.0. Check out the deprecation note from Appcelerator (linked below) to learn more.

    http://docs.appcelerator.com/titanium/3.0/#!/api/Titanium.Map

    Basically, what you want now is:

    var Map = require('ti.map'),
        annotation = Map.createAnnotation({ ... }),
        mapView = Map.createView({ ... });
    

    The docs for the module are here:

    http://docs.appcelerator.com/titanium/3.0/#!/api/Modules.Map