Problem
You can't pass an array of dictionaries {} to the annotations
property on a map view. But you CAN pass in an array of explicitly
created annotations Ti.Map.createAnnotation({ }). This use case
already works on iOS.
This contrasts with the "annotation" property, where you can
either pass in a Ti.Map.createAnnotation({ }), or simply a
dictionary {}.
Sample Code
The following will crash at runtime (as soon as you open the
app) if placed in an app.js:
var win = Ti.UI.createWindow({ backgroundColor: '#fff' });
win.add(Ti.Map.createView({
mapType: Ti.Map.STANDARD_TYPE,
regionFit: true,
region: { latitude: 50.8683, longitude: 6.0818, latitudeDelta: 0.01, longitudeDelta: 0.01 },
annotations: [
{
latitude: 50.8683, longitude: 6.0818, title: 'Rolduc Abbey'
}
]
}));
win.open();
BUT if we wrap the dictionary passed in to the annotation with
an explicit call to Ti.Map.createAnnotation it won't crash anymore.
Here is the code with only that one line updated:
var win = Ti.UI.createWindow({ backgroundColor: '#fff' });
win.add(Ti.Map.createView({
mapType: Ti.Map.STANDARD_TYPE,
regionFit: true,
region: { latitude: 50.8683, longitude: 6.0818, latitudeDelta: 0.01, longitudeDelta: 0.01 },
annotations: [
Ti.Map.createAnnotation({ // <-- this is the first line that changed
latitude: 50.8683, longitude: 6.0818, title: 'Rolduc Abbey'
}) // <-- this is the other line that changed
]
}));
win.open();
Tested On
Titanium SDK version: 1.7.0 (04/05/11 10:30 731db9c...)
BROKEN on Samsung Epic 4G Android 2.2
WORKS on iPhone Simulator 4.2
Associated Helpdesk Ticket
http://support-admin.appcelerator.com/display/RSN-92979-828
fixing tags.
App is not crashing now. Environment used for verification - Tested with Titanium SDK: 2.2.0.v20120827143312 , 2.1.1.GA,2.1.0.v20120628121617 Tested with Titanium Studio: 2.1.2.201208201549 Device - Android 2.2,2.3 emulator Machine OS - MAC 10.7.3