best practice to get user location using HTML5 geolocation

1k views Asked by At

I want to get user location on my website using HTML5 Geolocation.
To prevent user from getting a confirmation box when they visit my website, if the browser has Geolocation support I will show a small notification on website that ask the user to share his location and after user clicked on that notification browser asks for permission of sharing location, If I was able to get user location I will save lat/lng to a sessionStorage and I use it for that session.

Is there a better or standard way of getting user location?
Is there a way to know if user has granted permission for the website therefore instead of asking user every time to share location (using notification on website) I can call getCurrentPosition function and get user location?

0

There are 0 answers