Note that there are some explanatory texts on larger screens.

plurals
  1. POGet coordinates from Hardware GPS
    text
    copied!<p>I've found a lot of questions about GPS Coordinates but not one that confirms using the mobile hardware GPS instead of Web GPS like geoLocation and such like.</p> <p><strong>My actual method:</strong></p> <p>I'm using <code>navigator.geolocation.getCurrentPosition()</code>, the <code>Lat/Long</code> comes from the Web, here's the code:</p> <pre class="lang-js prettyprint-override"><code>function getGPS(funcCallBack) { if (navigator.geolocation) { var timeoutVal = getCookie("GPSTimeout"); navigator.geolocation.getCurrentPosition(sucess ,error ,{enableHighAccuracy: true ,timeout: timeoutVal ,maximumAge: 0} ); } else{ alert('GPS is turned off, or was not possible to find it. Now, doing the login without localization.'); window.gpsLat = 0; window.gpsLng = 0; window.gpsAcc = 0; funcCallBack(); } function sucess(position) //sucess { window.gpsLat = position.coords.latitude; window.gpsLng = position.coords.longitude; window.gpsAcc = position.coords.accuracy; funcCallBack(); } function error() //error { window.gpsLat = 0; window.gpsLng = 0; window.gpsAcc = 0; funcCallBack(); } } </code></pre> <p><strong>My problem:</strong></p> <p>Sometimes when I do the login I am not getting the GPS Coordinates (they come 0) and sometimes I am getting coordinates with more than 2,000 Accuracy (that is not precise).</p> <p>By the way, I am testing the GPS on a data internet service, when I do use a Wi-Fi connection it works perfectly with less than 100 Accuracy.</p> <p><strong>Details:</strong></p> <p>Maybe you are complaining about:</p> <ol> <li><code>timeoutVal</code>: it is a cookie with the number <code>5000</code> inside it.</li> <li><code>funcCallBack</code>: it is a function that continues the login operation.</li> <li><code>window.gpsLat</code>: it is a global var containing the <code>Latitude</code> value got from the <code>geoLocation</code>.</li> <li><code>window.gpsLng</code>: it is a global var containing the <code>Longitude</code> value got from the <code>geoLocation</code>.</li> <li><code>window.gpsAcc</code>: it is a global var containing the <code>Accuracy</code> value got from the <code>geoLocation</code>.</li> </ol> <p><strong>What do I want?</strong></p> <p>I want a solution in JavaScript or PHP that can get coordinates from the mobile hardware device, the Native GPS, not the geolocation, and when the Native GPS is turned off, ask the user to turn it on.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload