/    Sign up×
Community /Pin to ProfileBookmark

Is there a way to detect whether a user has already given permission for geolocation

Is there a way to detect whether a user has already given permission to use navigator.geolocation?

I can use localStorage, but the problem is in case the user clears location setting from browser. In this case user still gets true from local storage even though location settings are cleared.

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@rootJul 16.2014 — You can only best guess location based on the users IP. This I have to say is not accurate at all and having tried geoip services, my location either shows up as Birmingham or Luton and both those places are a couple of hours drive from me...
Copy linkTweet thisAlerts:
@xelawhoJul 16.2014 — there is a PERMISSION_DENIED error callback (error code 1) but (last time I looked anyway) firefox had a bug that it was not detecting when the user had denied permission

a good resource for geolocation stuff: http://diveintohtml5.info/geolocation.html
Copy linkTweet thisAlerts:
@rootJul 16.2014 — Having tried the demo, nowhere near where I live...

I live 3 hours drive from that location.

People need to take on board a simple fact that IP based location detection does not work for all users and when it does, you have provisional requirements like the IP address that the device connects to is in a known predetermined location.

Only true way to know someones location is via GPS or based on trust, ask the person.

[canned-message]attachments-removed-during-migration[/canned-message]
×

Success!

Help @litexnt spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...