1

I am using Angular and I am trying to get the user's current location to show some shops that are near. When I get the user location, it always becomes wrong, it gives me another location. (e.g. I am living in city 1, it gives me a location in city 2 )

this is the code I am using:

 if (window.navigator && window.navigator.geolocation) {
          window.navigator.geolocation.getCurrentPosition(
            position => { 
              this.geolocationPosition = position,
                console.log(position)
              this.userAltitude = +position.coords.latitude;
              this.userLongtitude = +position.coords.longitude
            }
)}
  • Possible duplicate of: https://stackoverflow.com/questions/3397585/navigator-geolocation-getcurrentposition-sometimes-works-sometimes-doesnt – Danon Aug 02 '20 at 17:50
  • Does this answer your question? [navigator.geolocation.getCurrentPosition sometimes works sometimes doesn't](https://stackoverflow.com/questions/3397585/navigator-geolocation-getcurrentposition-sometimes-works-sometimes-doesnt) – Danon Aug 02 '20 at 17:50
  • Refer this https://stackoverflow.com/questions/14580715/get-my-current-address-using-javascript – Janitha Rasanga Aug 02 '20 at 19:59

0 Answers0