Geolocation, Web Workers, History manipulation, undo, iFrame sandboxes, and other HTML5 specs laying the groundwork for a safer and smarter WebFollow @peterwayner
PERMISSION_DENIED to make it clear that the user didn't want to cooperate.
A nice feature includes a rough estimate of the accuracy along with the coordinates. There's a separate error range for the altitude because many GPS tools are less accurate in their estimates of the altitude than they are of the position on earth. The error estimates for the latitude and longitude, however, are the same, perhaps a mistake near the poles.
There are two major functions:
watchPosition. The first finds the position and the second wraps a loop around the process, generating an event only if there's a change. While
getCurrentPosition is pretty straightforward, I'm still wondering why
watchPosition doesn't have some parameter that defines just how much motion should trigger an event. There's just one parameter, the boolean
enableHighAccuracy, that "may or may not make a difference, depending on your hardware." What is high accuracy? That's a good question. So you get to implement your own loop wrapped around the loop in
Much of this detail is pretty hypothetical for desktop and laptop users, even when they're using a browser that has the capability. Although desktop browsers offer the geolocation object, the computers often don't provide any mechanism for generating even a guess at the location. There are tools that can list the Wi-Fi routers in range and use the information to identify the latitude and longitude with surprising accuracy, but these haven't caught on beyond tablets and smartphones. When the device has no way of locating itself, the API generates a
POSITION_UNAVAILABLE. To see if your browser supports the geolocation capabilities, try my test page at http://www.wayner.org/node/78.
HTML5 Web Workers