I am trying to use the geolocation API (version 2.5) with my Android 4.0.4 device, but I am not getting anything. I use the code from the telephone documentation. According to them, “if GPS and Wi-Fi are disabled, he should find you using triangulation of Cell Tower triangulation ”, but this code does not give anything to me. When I connected to Wi-Fi, it gives me the perfect place, but when there is no Internet, it will not work. I successfully work with all other call APIs, but only the geolocation API gives me problems. Please help me solve this problem.
And one more doubt, forgive me if this seems like a funny doubt .... I use a Wi-Fi connection in my mobile phone and never connect to other services (2G, 3G, etc.). Does Wi-Fi location search only detect Wi-Fi, or does it also include 2g and 3g connections?
Thnaks in Advance
<!DOCTYPE html>
<html>
<head>
<title>Device Properties Example</title>
<script type="text/javascript" charset="utf-8" src="cordova-2.5.0.js"></script>
<script type="text/javascript" charset="utf-8">
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
navigator.geolocation.getCurrentPosition(onSuccess, onError);
}
function onSuccess(position) {
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: ' + position.timestamp + '<br />';
}
function onError(error) {
alert('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
}
</script>
</head>
<body>
<p id="geolocation">Finding geolocation...</p>
</body>
</html>
Caught to know one thing .. It will not work with 2g and 3g .. only works with WIFI
source
share