HTML and CSS Reference
In-Depth Information
wait before giving up and triggering the error handler. However,
it won't start counting down if it's waiting for the user to approve
the request. If it does timeout, the error code is set to 3 ( TIME-
OUT ). Setting a zero timeout (the current default) tells the browser
to never time out and keep trying.
Finally, maximumAge tells the browser whether or not to use
recently cached position data. If there is a request that is within
the maximumAge (in milliseconds), it is returned instead of request-
ing a new position. maximumAge can also be Infinity , which
tells the browser to always use a cached position. Setting the
maximumAge to zero (the default value) means the browser must
look up a new position on each request.
How it works under the hood: It's magic
The geolocation API uses a few different techniques in acquiring the
user's position. It is black magic to most people, including myself, but
it's worth having an idea of what's going on under the hood as it will
affect the accuracy of the position data.
GPS is one of the obvious methods for getting position data. More
computing devices, ranging from mobile phones to laptops, are being
fitted out with GPS. Assuming there's a clear enough line to the GPS
ground station (which picks up readings from satellites to triangulate
the user's position—yep, more black magic), then you'll have a very
accurate reading. GPS can also give you altitude, speed, and heading,
which we saw in the second grade of properties in the coordinates
object when the high accuracy option was enabled.
Another method is using network information, which would be typical
if used via a desktop browser such as Firefox. The network information
could use Wi-Fi triangulation and IP addresses to make a best guess at
the user's location. The developer makes a call to the browser's geo-
location API, which in turn makes a call to a third-party service such
as Skyhook or Google. Although this may be less accurate than GPS,
it could make for a very good backup as GPS doesn't work very well
indoors or in high-rise urban locations.
Overall, it's not terribly important to know what makes geolocation tick,
but if you need to get the high accuracy, be wary of using the more
power-hungry devices such as GPS and of killing your user's battery.
All in all, it's some very cool black magic.
Search WWH ::

Custom Search