问题描述
是否有任何简单的方法来覆盖 geolocation api 的默认行为并且只是硬编码你现在的位置?
Are there any easy ways to override the default behaviors of the geolocation api and just hard code your current location?
我认为这对于测试和出于隐私原因(提供虚假位置数据)很有用
I think this would be useful for testing and for privacy reasons (providing fake location data)
我以为有一个附加功能,但我似乎找不到.现在唯一的选择似乎是将 about:config geo.wifi.url 更改为一些替代网络服务,我认为这过于复杂.
I thought there was an add on for this but I can't seem to find one. Only option right now seems to be changing the about:config geo.wifi.url to some alternative webservice, which I consider overly complicated.
有什么想法吗?
谢谢
理想场景
有人实现了一个显示谷歌地图的插件,我可以选择一个新的默认位置.
Somebody implements an add-on where a google map appears and I can pick a new default location.
推荐答案
geo.wifi.uri 不需要是 web 服务.您也可以使用 file://...
The geo.wifi.uri does not need to be a webservice. You can also set it to a local uri with file://...
文件应该是一个json文件,内容如下:
The file should be a json file with content like this:
{"location": {
"latitude": 48.777025000000002,
"longitude": 9.1713909999999998,
"accuracy": 10.0}}
更新:对于 Firefox 9+,格式已更改:
Update: For Firefox 9+, the format has changed:
{
"status": "OK",
"accuracy": 10.0,
"location": {"lat": 48.777, "lng": 9.171}
}
或者您可以将它们结合起来支持两者:
Or you can combine them to support both:
{
"status": "OK",
"accuracy": 10.0,
"location": {
"lat": 48.777,
"lng": 9.171,
"latitude": 48.777,
"longitude": 9.171,
"accuracy": 10.0
}
}
更新:看起来手动设置此首选项被假设为 Google 服务的提供商阻止.请参阅 错误 716453更新 2: geo.wifi.uri 不是 geo.wifi.url
Update: it looks like manually setting this preference is blocked by the provider assuming the Google service. See Bug 716453 Update 2: geo.wifi.uri not geo.wifi.url
这篇关于允许手动输入的 Firefox 地理定位提供程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!