Lowest Supported Browsers
IE 9.0+, Firefox 3.5+, Chrome 5.0+, Safari 5.0+, Opera 10.6+, iOS
Safari 3.2+, Opera Mobile 11.0+, and Android/Browser 2.1+/3.0+For current compatibility see here http://caniuse.com/geolocation
Geolocation API Specification
http://dev.w3.org/geo/api/spec-source.html Technology Used
Global Position System GPSAssisted GPS (A-GPS) cell site triangulation
Example JavaScript
//Check if browser supports W3C Geolocation API
if (navigator.geolocation) {
// single shot position request (others are repeat + cached)
navigator.geolocation.getCurrentPosition(successFunction, errorFunction);
}
else {
alert('Geolocation API is not supported by your browser.');
}
function successFunction(position) {
var lat = position.coords.latitude;
var long = position.coords.longitude;
alert('Your location coordinates are: Latitude:'+lat+' Longitude: '+long);
}
function errorFunction(position) {
alert('Error!');
}
code formatted here
No comments:
Post a Comment