Poornima-Open-Source-Society / Weather-App

find weather information around the world
https://weather-app-pce.netlify.app/
1 stars 6 forks source link

add live location feature #2

Open hardikhere opened 4 years ago

aakashsoni-cloud commented 4 years ago

`//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> }`

aakashsoni-cloud commented 4 years ago

This will help in using the user location by accessing it with the browser . It it decline or some error occur it give error.

hardikhere commented 4 years ago

You may implement on code and raise a pull request