`//Check for browser support the geolocation or not
if("geolocation" in navigator) {
navigator.geolocation.getCurrentPosition(setPosition, showError) //geoloaction get latitude and longitude of locations
} else {
notificationElement.style.display = "block";
notificationElement.innerHTML = "
Browser Does't support Geolocation.
";
}
//Set user position
function setPosition(position) {
let latitude = position.coords.latitude;
let longitude = position.coords.longitude;
getWeather(latitude, longitude);
}
`//Check for browser support the geolocation or not
if("geolocation" in navigator) { navigator.geolocation.getCurrentPosition(setPosition, showError) //geoloaction get latitude and longitude of locations } else { notificationElement.style.display = "block"; notificationElement.innerHTML = "
Browser Does't support Geolocation.
"; }//Set user position
function setPosition(position) { let latitude = position.coords.latitude; let longitude = position.coords.longitude; getWeather(latitude, longitude); }
//SHOW ERROR WHEN THERE IS ISSUE WITH LOCATION
function showError() { notificationElement.style.display = "block"; notificationElement.innerHTML =
<p> ${error.message} </p>
}`