سؤال

I'm trying to work out the watch position with android but its not working!!

<script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
<script type="text/javascript" charset="utf-8">

// Wait for PhoneGap to load
//
document.addEventListener("deviceready", onDeviceReady, false);

// PhoneGap is ready
//
function onDeviceReady() 
{
     watchID = navigator.geolocation.watchPosition(onSuccess, onError,{enableHighAccuracy: true,frequency: 3000 });
}

// onSuccess Geolocation
//
function onSuccess(position)
{
    alert("Successful!!");    
}

// onError Callback receives a PositionError object
//
function onError(error) {
    alert('code: '    + error.code    + '\n' +
          'message: ' + error.message + '\n');
}

</script>
هل كانت مفيدة؟

المحلول

Check the path to phonegap.js. When I changed your snippet to match the phonegap-1.1.0.js in my assets/www directory, the Successful!! alert popped up for me.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top