HTML and CSS Reference
In-Depth Information
Using the coordinate data, you could easily map the user's
current position on something like a Google map:
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function
¬ (position) {
var coords = position.coords;
showMap(coords.latitude, coords.longitude,
¬ coords.accuracy);
});
}
In a lot of applications, it's likely that the user will be offered
a manual way to set his current position. If the geolocation
method is available, the site may offer the advanced functional-
ity, progressively enhancing the page or the whole experience.
An example can be seen at http://owlsnearyou.com . When visit-
ing the site, if geolocation is available, it reloads the page with
your position loaded ( Figure 9.4 ), showing you where you can
go owl hunting, if that's the activity that gets you going after a
day of HTML5 development. If geolocation isn't available, it sim-
ply asks you to enter your location.
FIguRE 9.4 An example of
progressive enhancement using
geolocation.
 
Search WWH ::




Custom Search