user10078948
user10078948

Reputation: 51

navigator.geolocation.getCurrentPosition returning wrong results

When I use the geolocation service in the usual manner like for example :

if (navigator.geolocation) {
             navigator.geolocation.getCurrentPosition(showPosition1,errLocation, {maximumAge:0, timeout:40000, enableHighAccuracy:true});
            }
function showPosition1(position) {console.log(position.coords)}

I get a result which is extremely off. When I check using position.coord.accuracy, it shows to be 260 km! That is very far from where I am.

Any idea why this is the case even though highAccuracy is enabled and the browser permits location and everything?

I am using my mobile data's hotspot to connect to internet on my laptop. Can this be a big issue?

Upvotes: 5

Views: 2750

Answers (1)

Jeremy J Starcher
Jeremy J Starcher

Reputation: 23863

GeoLocation features use MANY different ways to figure out your location. In addition to the standard ways, Chrome at least one additional.

  • GPS co-ordinates -- If available, these are the most accurate.
  • Geo-IP -- Try to look up the IP address and find its location. This is known to be wildly inaccurate
  • (Chrome) Access Point Names -- The Google Maps van also collects Access Point (SSID) and their location. Chrome will use your current access point to try to find your location.

If your access point moved, it can throw off things. If you have to resort to Geo-IP, accuracy is a crap-shoot.

In addition, using proxy servers or VPNs will make Geo-IP useless.

Upvotes: 4

Related Questions