Hi All,
I had created an application using phonegap. I had added geolocation plugin in application
cordova plugin add org.apache.cordova.geolocation
I can able to see the plug in added in project.
Now I have created a location.html page in which I am using geolocation plugin :
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript">
document.addEventListener("deviceready",onDeviceReady,false);
function onDeviceReady(){
alert("Device Ready");
var options = { timeout: 60000 };
var optionsLocation={maximumAge: 60000,timeout:120000, enableHighAccuracy: true };
navigator.geolocation.getCurrentPosition(onSuccess,onError,optionsLocation);
}
function onSuccess(position)
{
alert("Yes, get location details..");
var str='Latitude: '+ position.coords.latitude + 'Longitude: ' + position.coords.longitude ;
alert(str);
}
function onError(error){
alert("Oops, No location details available, Please check GPS is running..");
switch(error.code)
{
case error.PERMISSION_DENIED:
alert("User did not share geolocation data.");
document.getElementById('locationDetails').innerHTML="User did not share geolocation data.";
break;
case error.POSITION_UNAVAILABLE: alert("Could not detect current position.");
document.getElementById('locationDetails').innerHTML="Could not detect current position.";
break;
case error.TIMEOUT: alert("Retrieving position timedout,Please try again");
document.getElementById('locationDetails').innerHTML="Retrieving position timedout,Please try again";
break;
default: alert("unknown error");
break;
}
}
</script>
I have specified 3 min as timeout, if I set this value to 10 min also getting same error
Retrieving position timedout,Please try again
What is going wrong here? Not getting geo location details.
All GPS settings are enabled on phone. I can able to see my current location with Google Map application.
config.xml :
<feature name="Geolocation">
<param name="android-package" value="org.apache.cordova.geolocation.GeoBroker" />
</feature>
Android manifest.xml :
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
Please guide to come out of this issue....
Thanks in advance for your help.
Regards,
Avinash