简体   繁体   English

如何在 Firefox 中调试 Geolocation API?

[英]How to debug Geolocation API in Firefox?

I've been trying to fix this issue for hours without success.我一直试图解决这个问题几个小时没有成功。 I hope to get a geolocation api genie to answer here.我希望得到一个地理定位 api 精灵来回答这里。 It's very simple, I'm just trying to get the api to ask for my position and then disclose it.很简单,我就是想弄个api去问我的位置然后公开。 It works well in Chrome, I get prompted and asked to disclose my location and then I can see my coordinates just fine.它在 Chrome 中运行良好,我收到提示并要求透露我的位置,然后我可以很好地看到我的坐标。

With Firefox, however, when I look in the console this is what I see when I click on the button但是,对于 Firefox,当我查看控制台时,这就是我单击按钮时看到的内容

RPC: got message Array(3) [ {…}, {…}, () ]common.js:341:15

What does this mean and how do I fix this?这是什么意思,我该如何解决?

This is my code :这是我的代码:

function getLocation() {

  if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(showPosition);
  } else { 
    alert("Geolocation is not supported by your browser. Please update your browser. Visit Help Center.");
  }
}

function showPosition(position) {
  var latitude = position.coords.latitude;
  var longitude =  position.coords.longitude;

  alert(latitude);

}

By the way, I tried running the code in W3Schools in Firefox and it's working fine on their server.顺便说一句,我尝试在 Firefox 中的 W3Schools 中运行代码,并且在他们的服务器上运行良好。 When I try run it in localhost, receive the RPC message in the console.当我尝试在 localhost 中运行它时,在控制台中接收到 RPC 消息。

I figured it out.我想到了。 For me, the problem came from one of the Firefox extension and preventing the Geolocation Api from disclosing location data.对我来说,问题来自 Firefox 扩展之一并阻止 Geolocation Api 披露位置数据。

Make sure you disable all your add-ons if you debug with Firefox...如果您使用 Firefox 进行调试,请确保禁用所有附加组件...

Yes, I've found that Location Guard gives a result like this to the console.是的,我发现 Location Guard 向控制台提供了这样的结果。 It's handy to know it's working, but just frustrating when you are trying to debug code and can't figure out what is producing those messages.知道它正在工作很方便,但是当您尝试调试代码并且无法弄清楚是什么产生了这些消息时,就会令人沮丧。

moz-extension://2d87d12b-9d4a-514b-9383-77925d2a5ad0/options.html#fixedPos moz-extension://2d87d12b-9d4a-514b-9383-77925d2a5ad0/options.html#fixedPos

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM