Re: Drop lastPosition from Geolocation?

Even more clear in code(*):

function successCallback(pos)
{
   // you can test timestamp to see
   // if pos is stale or not.

   // do something geofantastic
}

function errorCallback(error)
{
   switch(error.code)
   {
      case POSITION_UNAVAILABLE:
         alert("position not available (cached or otherwise)");
         break;

      case PERMISSION_DENIED:
         alert("the page has no permission");
         break;

      case TIMEOUT:
         alert("timeout");
	break;

      default:
         alert("no idea");
   }
}


(*) the error codes should be something like  
"navigator.geolocation.PositionError.<NAME>".

Doug

On Nov 19, 2008, at 10:06 AM, Greg Bolsinga wrote:

> +1, very nice and clear. -- Greg
>
> On Nov 19, 2008, at 10:03 AM, Andrei Popescu wrote:
>
>> Ok, so for the following call
>>
>> geolocation.getCurrentPermission(successCallback, errorCallback,
>> {modifiedSince:600, timeout:0});
>>
>> the new behavior is the following:
>>
>> - if the page has no permission, errorCallback is invoked with
>> PERMISSION_DENIED.
>> - else
>> * if it doesn't have any cached position, errorCallback is invoked
>> with POSITION_UNAVAILABLE.
>> * else
>>    ** if the cached position is older than 10 mins, errorCallback is
>> invoked with POSITION_UNAVAILABLE
>>    ** else successCallback is immediately invoked with the cached  
>> position
>

Received on Wednesday, 19 November 2008 18:20:18 UTC