javascript - 如何测试地理位置 javascript?

标签 javascript geolocation

我目前正在处理一些地理定位 javascript,但无法正确测试和调试它们:我的台式机(运行 Windows,使用 Chrome 5 或 Firefox 3)没有位置信息,我的移动设备也没有具有任何调试功能。

如何测试地理定位脚本?是否有可以伪造 GPS 传感器的工具?

最佳答案

在 Firefox 中,可以将默认的地理位置提供程序 (Google) 切换为手动输入的来源。

Fake your geolocation in Firefox 3.5

All you need for faking is a text file (eg. /home/username/.mynewlocation.txt) somewhere on your computer with the following content: {"location":{"latitude":50.941863,"longitude":6.958374, "accuracy":20.0}}

The path in Firefox to this file is: file://home/username/.mynewlocation.txt

Type about:config in your location bar, confirm the warning, search for geo.wifi.url, and replace the old url (https://www.google.com/loc/json) with your new one from above. Restart firefox, enjoy your new location :-)

还有 a similar SO question还有一些很好的答案。

关于javascript - 如何测试地理位置 javascript?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3184731/

相关文章:

javascript - 如何将 JavaScript 文件导入 Stencil 组件?

javascript - document.querySelectorAll ('a:visited' ) 不起作用

javascript - 如何将表行传递到包含所有输入元素的隐藏表单?

Android:如何初始化 "Location"类型的变量(除了使其等于 null)

ios - Swift 从 CLLocation 获取 CLPlacemark

javascript - 如何使用 JavaScript 将 DateTime 的 C# 输出转换为 "Days Remaining"?

javascript - 将变量从 ASP.net 传递到 JavaScript

database - 是否有可以查询本地城市名称的公共(public)地理定位系统?

android - 在 Android 中的谷歌地图位置上设置名称和标题

ios - 开始工作 Ionic + ngCordova + 后台地理定位