HTML and CSS Reference
In-Depth Information
see if the position is unavailable for some other reason or if the user does not respond in a
timely manner.
A function that gets the latitude and longitude by calling the
and coords.longitude() functions, respectively, for the object returned from the
geolocation.getCurrentPosition() function.
Here's some sample code that meets all the geolocation criteria to return the user's latitude and
function initiate_geolocation() {
function handle_errors(error)
case error.PERMISSION_DENIED: alert(“user did not share geolocation data”);
case error.POSITION_UNAVAILABLE: alert(“could not detect current position”);
case error.TIMEOUT: alert(“retrieving position timed out”);
default: alert(“unknown error”);
function handle_geolocation_query(position){
alert('Lat: ' + position.coords.latitude +
' Lon: ' + position.coords.latitude);
Once you have the user's position in the form of the latitude and longitude, you can use those details
to map the location or locate services and businesses in the area.
Browsers that currently support geolocation include:
Internet Explorer 9.0 (beta)
Firefox 3.5+
Safari 5.0+
Google Chrome 5.0+
Opera 10.6+
Search WWH ::

Custom Search