HTML and CSS Reference
In-Depth Information
FIGURE 9.3 Mobile Safari with
a model dialog, blocking the app
from continuing.
API methods
The geolocation API exists inside the navigator object and con-
tains only three methods:
The watchPosition and clearWatch are paired methods. The
watch and clear methods work the same way that setInterval
and setTimeout work. watchPosition returns a unique identifi er
that is passed in to clearWatch to clear that particular watch.
As I mentioned before, both getCurrentPosition and watchPosition
mirror each other and take the same arguments:
success handler
error handler
geolocation options
Simple usage of the geolocation API would be to pass a suc-
cess handler to the getCurrentPosition method:
navigator.geolocation.getCurrentPosition(function (position) {
alert('We found you!');
// now do something with the position data
Search WWH ::

Custom Search