I am currently working on the local weather intermediate project. It is very frustrating, because google chrome has been taking extremely long to display my location when I allow access. I know the function is working, because I console.log it as well. No matter if I write it locally on my computer or if I write it on codepen, both either don’t display the location for a very long time, when I check back on the page 20-30 mins later, or just doesn’t show it at all after 30+ min, even though everything is working correctly, functionality wise.
Very rarely it will show instantly. Maybe one out of 30 tries it will show as soon as I load the page.
A few days ago, codepen was taking very long to show the location. When I wrote the file locally, it was showing the location instantly. Now, neither is working.
Tried on 2 different computers as well. I’m starting to think it has something to do with chrome? Has anyone else experienced this issue?
Just for clarification, this is my JS
var latLong = document.getElementById("latLong");
var lat = document.querySelector("#lat");
var long = document.querySelector("#long")
function myPosition (position){
lat.textContent = position.coords.latitude;
long.textContent = position.coords.longitude;
}
if (navigator.geolocation){
navigator.geolocation.getCurrentPosition(myPosition)
console.log("showing location ")
}
else {
latLong.innerHTML = "sorry, position not avaliable"
}