Problem
The "country code" property is inconsistent between the platforms. On iOS it is "country_code", while for Android it is "CountryCode".
Solution
Pick one, and deprecate the other. Both platforms should expose the one chosen, and one can have the antiquated property for a couple more releases.
Sample Code
Ti.Geolocation.addEventListener('location', function(e) {
Ti.Geolocation.reverseGeocoder(e.coords.latitude, e.coords.longitude, function(evt) {
alert(evt);
});
});
Associated Helpdesk Ticket
http://appc.me/c/APP-455583
Dawson, Please update the sample code attached to this bug that exhibits the problem. I think that "country_code" would work on both platforms.
"country_code" only works on iOS. Android return value does not contain this property. I just verified this statement is true on device, and in the source code using Release 1.7.1 and a build from source 6f5ab67357aa358d413f. See: https://github.com/appcelerator/titanium_mobile/blob/master/android/modules/geolocation/src/ti/modules/titanium/geolocation/TiLocation.java#L352 And for the constant's definition see: https://github.com/appcelerator/titanium_mobile/blob/master/android/titanium/src/org/appcelerator/titanium/TiC.java#L137
Updated example code.
Additional (simpler) test if you're having problem with GEO on your device. This test just tests the affected code, which is the reverse geo lookup. The result should refer to Austria, since I'm giving the coordinates to Vienna, Austria here:
Tested with 1.8.0.v20110819142548 iPhone 4.3.4 iPad2 4.3.2 Motorola Xoom 3.2 Nexus One 2.2.2