2

これはTitaniumAppceleratorの私のコードです:

  function ApplicationWindow(title) {
    var self = Ti.UI.createWindow({
        title:title,
        backgroundColor:'white'
    });

        var button = Ti.UI.createButton({
        height:44,
        width:200,
        title:L('openWindow'),
        top:200
    });


    self.add(button);

    function getPosition() {
        alert("In the Function");
        Titanium.Geolocation.getCurrentPosition(function(e) {
                    Titanium.Geolocation.distanceFilter = 10;
                    Ti.Geolocation.preferredProvider = "gps";

                    if (e.error) {
                        Ti.UI.createAlertDialog({
                            title: L('geolocate_failure'),
                            message: e.error
                        }).show();
                        return;
                    }
                    var found = new Object();
                    locateIndicator.show();
                    found.longitude = e.coords.longitude;
                    found.latitude = e.coords.latitude;
                    found.altitude = e.coords.altitude;
                    found.heading = e.coords.heading;
                    found.accuracy = e.coords.accuracy;
                    found.speed = e.coords.speed;
                    found.timestamp = e.coords.timestamp;
                    found.altitudeAccuracy = e.coords.altitudeAccuracy;
                    return found
                });
    }

 button.addEventListener('click', function() {
        alert("button click");
        getPosition();
    });
    return self;
};

module.exports = ApplicationWindow;

このコードをAndroidEmulatorで実行すると、「現在、場所は利用できません」というポップアップが表示されます。これは、このコードをモバイルで実行するまで(GPSが有効)、GPS関連の出力が得られないことを意味しますか?またはそれは私のコードに何かありますか?
ありがとうございました。

4

1 に答える 1

2

エミュレータでジオロケーションサービスを実行する場合は、緯度と経度をddmsで設定する必要があります。

于 2012-07-23T08:31:04.677 に答える