帮助我了解英特尔XDK地理位置

时间:2016-07-18 07:08:55

标签: javascript geolocation intel-xdk

我正在尝试学习英特尔XDK地理位置。我希望有人能够教会我如何使用地理定位。请注意,我在Javascript中的知识有限。

<script>
//I believe I should be creating variable here
var lat ="";
var long ='';

 //I understand this. event listener when the device is ready and if its ready call onDeviceReady function.

    document.addEventListener("deviceready", onDeviceReady, false);

           //The on device ready function which I believe I can call the   geolocation method
    function onDeviceReady() {
    //my attempt to  get navigation. I have no Idea what should I do here
     navigator.geolocation.getCurrentPosition(geolocationSuccess,
                                             [geolocationError],
                                             [geolocationOptions]);
    }       

    var onSuccess = function(position) {
        alert('Latitude: '          + position.coords.latitude          + '\n' +
              'Longitude: '         + position.coords.longitude         + '\n' +
              'Altitude: '          + position.coords.altitude          + '\n' +
              'Accuracy: '          + position.coords.accuracy          + '\n' +
              'Altitude Accuracy: ' + position.coords.altitudeAccuracy  + '\n' +
              'Heading: '           + position.coords.heading           + '\n' +
              'Speed: '             + position.coords.speed             + '\n' +
              'Timestamp: '         + position.timestamp                + '\n');
    };
        function onError(error) {
        alert('code: '    + error.code    + '\n' +
              'message: ' + error.message + '\n');
    }           
</script>

我不知道我在做什么。请帮助我。

0 个答案:

没有答案