544 CHAPTER 14 Making your HTML location-aware
In this example, the showError function is called if there is an error when calling the
getCurrentPosition method. An error object is passed to the showError function. This example
attempts to determine the cause of the error and display a meaningful message.
Addressing privacy
If a webpage can get your current position, is that an invasion on your privacy? Yes, and you
will receive a prompt that says, “DomainName wants to track your physical location.” At that
point, you can decide whether you want your location to be retrieved once, all the time, or
not at all. Figure 14-2 shows the prompt.
FIGURE 14-2 he request for location trackingT
Specifying options
The third parameter that you can pass to the getCurrentPosition method is the options, which
is a PositionOptions object that provides you with the following optional properties.
■■enableHighAccuracy his specifies that the best possible result is requested even if T
it takes more time. Default is false.
■■timeout his specifies the timeout in milliseconds that the browser will wait for a T
response. Default is -1, which means there is no timeout.