2

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?

Masoud
  • 333
  • 1
  • 10
  • 2
    Check this answer: http://stackoverflow.com/a/37750156/530351 Looks like there's an API which allows to query permissions, though it may not be available everywhere, but I guess browser should cache user`s response for some time. – Igor Nikolaev Jan 02 '17 at 20:06

0 Answers0