I am developing a blackberry application using html5 code.I need to find my current location and have to show that in Google map.I am running this in BB9780. It is running in simulator but it gives a wrong location(US location). But it is not running in device.
I suspect the below line is not executing.
navigator.geolocation.getCurrentPosition(onSuccess, onError);
I am giving my code here.Please suggest me where I went wrong
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" id="viewport" content="width=device-width,height=device- height,initial-scale=1.0,user-scalable=no">
<script src="json2.js" type="text/javascript"></script>
<script src="cordova-1.7.0.js" type="text/javascript"></script>
<script type="text/javascript" charset="utf-8">
// Wait for Cordova to load
document.addEventListener("deviceready", onDeviceReady, false);
// Cordova is ready
function onDeviceReady() {
alert("onDeviceReady");
navigator.geolocation.getCurrentPosition(onSuccess, onError);
}
// onSuccess Geolocation
function onSuccess(position) {
alert("onSuccess");
var element = document.getElementById('geolocation');
element.innerHTML = 'Latitude: ' + position.coords.latitude + '<br />' +
'Longitude: ' + position.coords.longitude + '<br />' +
'Altitude: ' + position.coords.altitude + '<br />' +
'Accuracy: ' + position.coords.accuracy + '<br />' +
'Altitude Accuracy: ' + position.coords.altitudeAccuracy + '<br />' +
'Heading: ' + position.coords.heading + '<br />' +
'Speed: ' + position.coords.speed + '<br />' +
'Timestamp: ' + new Date(position.timestamp) + '<br />';
}
// onError Callback receives a PositionError object
function onError(error) {
alert('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
}
</script>
<title>Notification Sample</title>
</head>
<body>
<p id="geolocation">Finding geolocation...</p>
</body>
</html>