javascript - navigator.geolocation giving wrong results - Stack Overflow

I'm working on a webapp that can use geolocation to do cool things, and right now I'm just lo

I'm working on a webapp that can use geolocation to do cool things, and right now I'm just lost because navigator.geolocation is giving me wrong results.

My debug code :

navigator.geolocation.getCurrentPosition(
    function(p) {console.log(p.coords)},
    function(p) {console.log('bug')},
    {enableHighAccuracy: true}
)

the result :

Coordinates {speed: null, heading: null, altitudeAccuracy: null, accuracy:  140843, altitude: null…}
    accuracy: 140843
    altitude: null
    altitudeAccuracy: null
    heading: null
    latitude: 46.1902742
    longitude: 6.1464840999999995
    ...

The problem is : The coordinates are plain wrong. I'm not in Geneva at all. I'm in another part of Switzerland.

And this problem happens on my puter, on my friend puter, on linux puters, on windows puters, on mac puters.

What is the problem ? Is navigator.geolocation obselet ? not working in switzerland ? I'm just missing something ?

I'm working on a webapp that can use geolocation to do cool things, and right now I'm just lost because navigator.geolocation is giving me wrong results.

My debug code :

navigator.geolocation.getCurrentPosition(
    function(p) {console.log(p.coords)},
    function(p) {console.log('bug')},
    {enableHighAccuracy: true}
)

the result :

Coordinates {speed: null, heading: null, altitudeAccuracy: null, accuracy:  140843, altitude: null…}
    accuracy: 140843
    altitude: null
    altitudeAccuracy: null
    heading: null
    latitude: 46.1902742
    longitude: 6.1464840999999995
    ...

The problem is : The coordinates are plain wrong. I'm not in Geneva at all. I'm in another part of Switzerland.

And this problem happens on my puter, on my friend puter, on linux puters, on windows puters, on mac puters.

What is the problem ? Is navigator.geolocation obselet ? not working in switzerland ? I'm just missing something ?

Share Improve this question edited Dec 2, 2021 at 23:47 Samvel Aleqsanyan 2,9744 gold badges21 silver badges28 bronze badges asked Feb 20, 2015 at 8:41 Spoutnik16Spoutnik16 8641 gold badge12 silver badges19 bronze badges 8
  • are you using same internet connection always? Is a VPN? Lan/VPN connections can be redirected through other physical places. – Jordi Castilla Commented Feb 20, 2015 at 8:47
  • it is a lan connection, same corporate network. But I've set no VPN up (and I'm managing that network). – Spoutnik16 Commented Feb 20, 2015 at 8:53
  • 140km is a really high value for accuracy... Have you tried enabling enableHighAccuracy in the options? .getCurrentPosition(successCallback, errorCallback, options), PositionOptions – Andreas Commented Feb 20, 2015 at 9:04
  • yeah, same results (edited the main to add it) – Spoutnik16 Commented Feb 20, 2015 at 9:09
  • What if you try another site that tells you your location? I mean, same network, other website? Such as html5demos./geo – Jonas Grumann Commented Feb 20, 2015 at 9:12
 |  Show 3 more ments

1 Answer 1

Reset to default 4

Do you have GPS-dongle connected to PC ? Or geolocation source is any wrong IP-geo tool or Wifi/Cell. You can't get your exact physical coordinates by IP-address. If you use WiFi network accuracy can be 5-50 meters, but you are using LAN. Geolocation by IP is very very inaccurate, it's normaly to get wrong city or country.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745479401a4629496.html

相关推荐

  • javascript - navigator.geolocation giving wrong results - Stack Overflow

    I'm working on a webapp that can use geolocation to do cool things, and right now I'm just lo

    2小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信