admin管理员组文章数量:1430704
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 enablingenableHighAccuracy
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
1 Answer
Reset to default 4Do 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.
本文标签: javascriptnavigatorgeolocation giving wrong resultsStack Overflow
版权声明:本文标题:javascript - navigator.geolocation giving wrong results - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745479400a2660112.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论