Applelerator Geolocation не работает на Android - PullRequest
0 голосов
/ 11 ноября 2011

Следующий код из примера Titanium отлично работает на iPhone, но не на Android. Может кто-нибудь показать мне, как это можно написать, чтобы оно работало и на Android 2.3.3? Ошибка не отображается, если я закомментирую «Ti.Geolocation.getCurrentPosition» и его конечный тег.

if (!_bounty.captured) {
    var captureButton = Ti.UI.createButton({
        title:L('capture'),
        top:10,
        height:30,
        width:200
    });
    captureButton.addEventListener('click', function() {
        if (Ti.Geolocation.locationServicesEnabled) {
            Ti.Geolocation.accuracy = Ti.Geolocation.ACCURACY_BEST;
            Ti.Geolocation.getCurrentPosition(function(e) {  //*causes error on Android*
                var lng = e.coords.longitude;
                var lat = e.coords.latitude;
                bh.db.bust(_bounty.id, lat, lng);

                bh.net.bustFugitive(Ti.Platform.id, function(_data) {
                    Ti.UI.createAlertDialog({
                        message:_data.message
                    }).show();

                    //on android, give a bit of a delay before closing the window...
                    if (Ti.Platform.osname == 'android') {
                        setTimeout(function() {
                            win.close();
                        },2000);
                    }
                    else {
                        win.close();
                    }
                });
            });
        }
        else {
            Ti.UI.createAlertDialog({
                title:L('geo_error'), 
                message:L('geo_error_details')
            }).show();
        }
    });
    win.add(captureButton);
}

Любая помощь приветствуется.

1 Ответ

0 голосов
/ 14 ноября 2011

Вы должны использовать Google API SDK, чтобы использовать геолокацию на Android

...