简体   繁体   中英

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. It's very simple, I'm just trying to get the api to ask for my position and then disclose it. It works well in Chrome, I get prompted and asked to disclose my location and then I can see my coordinates just fine.

With Firefox, however, when I look in the console this is what I see when I click on the button

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. When I try run it in localhost, receive the RPC message in the console.

I figured it out. For me, the problem came from one of the Firefox extension and preventing the Geolocation Api from disclosing location data.

Make sure you disable all your add-ons if you debug with Firefox...

Yes, I've found that Location Guard gives a result like this to the console. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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