Get geolocation: invalid navigator.geolocation.getCurrentPosition

In the case of

MDN, the local operation does not print the geographical location, nor does it report an error. Why? Ask for instructions
at the beginning, the PC side has been returning a timeout. It may be because the PC side does not support it. After opening it with your mobile phone, you will be prompted: error.code 1 PERMISSION_DENIED

.

Mobile phone Google browser error: err.code 1, does not allow access to geographical location, how to solve?
where can I reopen the allow or how does js modify whether it is allowed?

    var options = {
      enableHighAccuracy: true,
      timeout: 5000,
      maximumAge: 0
    };
    
    function success(pos) {
      var crd = pos.coords;
    
      console.log("Your current position is:");
      console.log("Latitude : " + crd.latitude);
      console.log("Longitude: " + crd.longitude);
      console.log("More or less " + crd.accuracy + " meters.");
    };
    
    function error(err) {
      console.warn("ERROR(" + err.code + "): " + err.message);
};

navigator.geolocation.getCurrentPosition(success, error, options);

clipboard.png


navigator.geolocation.getCurrentPosition doesn't seem to work in Google browser, but other browsers can. The specific reason is not clear


getCurrentPosition is asynchronous, and the result is not returned immediately after the call.

the error message has already been printed in your screenshot, which is ERROR (3): Timeout expired ), indicating that the request timed out.


I have a similar problem. Using geolocation.getCurrentPosition always returns error code 3. Ask for advice

Menu