I am using the phonegap geolocation API in phoneroid android application. It always shows error code 3, timeout error. I am also trying to change the value of the timeout variable to an increased one, enableHighAccuracy will be true.But there will be no change in result.But it will work in a browser that does not start in the application. Give me a solution to this problem.
This is my code.
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no" /> <link rel="stylesheet" href="css/contact.css" type='text/css' /> <link rel="stylesheet" href="css/jquery.mobile-1.3.1.min.css" type='text/css' /> <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=AIzaSyCJAbwOQjaVjDy9XJ0UEZCvTdZeW_atXak&sensor=false"> </script> <script type="text/javascript" charset="utf-8" src="cordova-2.9.0.js"></script> <script src="jquery.mobile/jquery-1.10.2.min" type='text/javascript'></script> <script> document.addEventListener("deviceready", onDeviceReady, false); $(document).on("mobileinit", function() { $.mobile.phonegapNavigationEnabled = true; $.support.cors = true; $.mobile.allowCrossDomainPages = true; $.mobile.loadingMessageTextVisible = true; $.mobile.pageLoadErrorMessage; }); $(document).ready(function() { $('#Login').show(); $('#Contacts').hide(); }); function success(name) { alert(name); } function error() { alert("error"); } function login() { var name = $("#name").val(); if (navigator.notification) { navigator.notification.alert("Welcome " + name, alertDismissed, 'Sample App', 'Ok'); } else { alert("Welcome " + name); } var options = { enableHighAccuracy: true, timeout: 8000, maximumAge: 10000 }; navigator.geolocation.getCurrentPosition(onSuccess, onError, options); $("#Login").hide(); $("#Contacts").show(); } function alertDismissed() { console.log("ok"); } function onSuccess(position) { var latt1 = position.coords.latitude; var lont1 = position.coords.longitude; </script> <script src="jquery.mobile/jquery.mobile-1.3.1.min.js" type='text/javascript'></script> </head> <body> <div data-role="page" > <div id="Login"> <div data-role="header" data-position="fixed" data-theme="b" data-tap-toggle="false" class="header" data-transition="none" id="myFixedHeader"> <p>Sample Application</p> </div> <div data-role="content"> <div id="title"> <div style="width: 90%; padding-left: 5%; padding-right: 5%; padding-top: 3%; padding-bottom: 1%;"> <input type="text" name="password" id="name" data-mini="true" placeholder="Enter Your Name " value="" data-inline="true"> </div> <center> <div id="log" onclick="login()">Login</div> </center> </div> </div> <div data-role="footer" data-theme="b" data-position="fixed" class="footer" data-transition="none" data-tap-toggle="false"> <p onclick="goHome()">© 2014 Sample App Reserved, LLC.</p>> </div> </div> <div id="Contacts"> <div data-role="header" data-theme="b" data-tap-toggle="false" data-position="fixed" class="header" data-transition="none"> <h3 id="htitle">Home Page</h3> </div> <div data-role="content" id="map_canvas" > </div> <div data-role="footer" data-theme="b" data-position="fixed" class="footer" data-transition="none" data-tap-toggle="false"> <p onclick="goHome()">© 2014 Sample App Reserved, LLC.</p> </div> </div> </body> </html> I have added Permissions INTERNET,FINE_LOCATION,COARSE_LOCATION in manifest file and corrova 2.9.0.js
android cordova phonegap-plugins
prakash
source share