navigator.geolocation 给出错误的结果

Spo*_*k16 1 javascript geolocation

我工作的web应用程序,可以使用地理位置做很酷的事情,而现在我只是失去了,因为navigator.geolocation是给我错误的结果。

我的调试代码:

navigator.geolocation.getCurrentPosition(
    function(p) {console.log(p.coords)},
    function(p) {console.log('bug')},
    {enableHighAccuracy: true}
)
Run Code Online (Sandbox Code Playgroud)

结果 :

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
    ...
Run Code Online (Sandbox Code Playgroud)

问题是:坐标完全错误。我他妈的根本不在日内瓦。我在瑞士的另一个地方。

这个问题发生在我的电脑上,在我朋友的电脑上,在 linux 电脑上,在 windows 电脑上,在 mac 电脑上。

问题是什么 ?navigator.geolocation 过时了吗?不在瑞士工作?我只是错过了什么?

Der*_*zer 5

你有连接到 PC 的 GPS 软件狗吗?或者地理定位来源是任何错误的 IP 地理工具或 Wifi/Cell。您无法通过 IP 地址获得确切的物理坐标。如果您使用WiFi网络精度可以是5-50米,但您使用的是局域网。通过 IP 进行地理定位非常不准确,错误的城市或国家/地区是正常的。