Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-3558] Android: Map Annotations Array Doesn't Accept Dictionary

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2012-05-16T16:47:10.000+0000
Affected Version/sRelease 1.7.0, Release 2.0.1
Fix Version/sRelease 2.1.0, Sprint 2012-10 API
ComponentsAndroid
Labelsapi, parity, qe-port, training
ReporterDawson Toth
AssigneeVishal Duggal
Created2011-04-15T03:46:39.000+0000
Updated2012-08-28T02:25:57.000+0000

Description

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

Comments

  1. Don Thorp 2011-04-15

    fixing tags.

  2. Shyam Bhadauria 2012-08-28

    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

JSON Source