W3C home > Mailing lists > Public > public-geolocation@w3.org > March 2011

Mechanism to determine whether location is currently being shared

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Wed, 2 Mar 2011 14:02:25 -0800
Message-ID: <AANLkTin6TGrEQE-C59uZ3ctfaaqpX=GmFvq_ZpFoUvVh@mail.gmail.com>
To: public-geolocation@w3.org
Cc: olalonde@gmail.com
Heya, Geoloc people!

(Note: I am not subscribed to this list, nor is the developer that I
discussed this issue with (cc'd).  Please ensure that I and the cc'd
developer stay on the cc list for this thread.)

A developer recently asked me for some way to tell, in the
getCurrentPosition callback, whether the permission grant was due to
the user actually seeing the permissions prompt and clicking "Allow"
(or the equivalent), or if it was an automatic grant due to the user
previously granting the site permanent access to their location.  This
can alternately be cast as a request to know if the user has already
granted permission to grab their location, such that a call to
getCurrentPosition() will return a position without prompting the
user, or not.

By carefully reading the Geolocation spec, I learned that this case
had already thought about, and can be addressed as follows:

  function(){ /* This fires if the user has previously granted permission.*/ },
  function(){ /* This fires if they didn't. */ },
  { maximumAge: 1e20, timeout: 0 }

However, this still misses one case - when the user has already
granted permission to share their location, but there are no cached
positions.  This can happen if, for example, the user instructs their
browser to always share their location, or if the browser's position
cache is cleaned (either automatically or at the user's instruction).

As well, having to specify an arbitrary large value for maximumAge to
ensure that you'll get a cached position if one exists is pretty

Finally, it requires careful reading of the spec to determine that
this is even possible.  An example or two would have helped.  ^_^

I propose that Geolocation address this use-case directly, either by
providing a boolean property on Geolocation reflecting whether the
user has granted the site permission to grab their location, or a
function that takes a single callback and provides the boolean value
as an argument to the callback.

Received on Wednesday, 2 March 2011 22:03:17 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:51:02 UTC