gpt4 book ai didi

javascript - 如何设置纬度和经度以使用 Google Chrome 调试 Geolocation API?

转载 作者:可可西里 更新时间:2023-11-01 01:57:00 27 4
gpt4 key购买 nike

对于我的开发系统,我希望能够在 Chrome 中设置地理位置(纬度、经度),这样当我进行测试时,浏览器会认为我在位置 X,而实际上我可能在位置Y.

有谁知道如何强制 Google Chrome 使用我提供的纬度和经度作为位置?

最佳答案

如果您谈论的是 Geolocation API,则可以覆盖该函数:

navigator.geolocation.getCurrentPosition = function(success, failure) { 
success({ coords: {
latitude: 30,
longitude: -105,

}, timestamp: Date.now() });
}

因此,当库调用 navigator.geolocation.getCurrentPosition 函数时,您指定的坐标将被返回。

关于javascript - 如何设置纬度和经度以使用 Google Chrome 调试 Geolocation API?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5505617/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com