TransWikia.com

why does geolocation not work on mobile browsers and desktop?

Stack Overflow Asked by morteza on December 6, 2020

I am trying to get the location of the user with HTML5 geolocation. On Desktop Gives this error when I grant access 2: Network location provider at ‘https://www.googleapis.com/’: No response received. And when I test on a mobile phone, it does not ask the access question and error 1: User denied Geolocation

this is my code:

successHandler(position) {
  console.log(position)
  alert(position.coords.latitude)
  alert(position.coords.longitude)
},
errorHandler(errorObj) {
  alert(errorObj.code + ": " + errorObj.message);  
},
getLocation() {
  if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(this.successHandler, this.errorHandler, {
      enableHighAccuracy: true,
      maximumAge: 10000,
      timeout: 10000
    })
  } else {
    alert("Geolocation is not supported by this browser.");
  }
}
created() {
  this.getLocation()
},

I am using Google Chrome on all devices.

One Answer

  1. Geolocation on Google Chrome requires connection with Google. As a result, if you are in a region where Google is banned, it cannot provide location service.
  2. As other guys mentioned, geolocation requires HTTPS.

Answered by Yutong Zhang on December 6, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP